Common MySQL Commands

Command To Connect To MySQL Server :

mysql -u username -p password -h hostname -Pportnumber

Backup All The Databases From MySQL Server :

mysqldump -uroot -p password –all-databases > c:\backup_all_db.sql

Import SQL File To Specific Database In MySQL Server :

mysqldump -h hostname -uroot -proot -Pportnumber testdb < testdb.sql

Backup Specific Database From MySQL Server :

mysqldump -uroot -proot  –databases testdb > e:\ testdb.sql

Delete MySQL Service From Windows :

sc delete MySQLServiceName;

Configuration Of Slow Query Log Into MySQL ( In my.ini )



log-slow-queries = c:/slowqueries.log


Command To Repair MySQL Event scheduler damaged :

mysql_upgrade -uroot -hlocalhost -proot –verbose

Command To Dump gz file Into MySQL Database (Linux Box ) :

gunzip < /pathtofile/dbdump.sql.gz | mysql -uroot -proot –D testdb

Command To Export Stored Procedures & Triggers From Specific MySQL Database :

mysqldump -h hostname -uusername -ppassword -Pportnumber  –routines –no-create-info –no-data –no-create-db –skip-opt testdbname > exportsptriggers.sql

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s