Tutorial for mySQL deployment - GiannisAnasta/Companies GitHub Wiki
First: You have to open the terminal and change directory in your main project you want to deploy "cd CompaniesFinal" (in my situation) and then type "glassfish4/glassfish/bin/asadmin start-domain domain1" to start your glassfish localhost.
Second: After you started your gflocalhost change directory to you project "cd Companies" and then type "git pull" in your terminal (which is located in your project as we said in the first step) so any changes you have made to be applied.
Third: Type "mvn clean install" in your terminal so you can clean and build your project.
Fourth: type "cd ../" in your terminal so you will go back one folder and then type "mysqldump
--host="localhost" --user="root" --password="******" companies > datadumps/01-01-0001.sql" this is needed to create a dump of your previous mySQL database.
Fifth: go to your localhost source (glashfish open source in my case 'localhost:4444') and then click "Applications" which is located on your left in the "Common tasks" tree/column. If you have already a deployed application "undeploy" it and "deploy" it again, if you don't then just click "deploy". Then you'll have to browse your applications .war file which is located inside your you main project/target/????.war. After you clicked your .war change the context root to "/" and application name to your needs (mine are "companies") those two by default are with same name in most cases.
Sixth: If there are some errors you can try to restart you localhost domain by stoping it " glassfish4/glassfish/bin/asadmin stop-domain domain1" and then start it again " glassfish4/glassfish/bin/asadmin start-domain domain1". Dont forget to change directory to your main folder ("cd CompaniesFinal" in my case) because your glassfish is located there.