Helpful MySQL Commands

Secure MySQL after a new installation.


Create a MySQL server database.

mysqldump -uroot -p database-name > database.sql


mysqldump -uroot -p old_db > db1.sql
Enter your user password, in this case root, at the prompt. This command can also be ran with a database user with the right permissions. Take note of the greater than sign being used. Think of it as an arrow as to the direction that you want the data to flow. That is how I remember the difference in this command, as it’s easy to associate the two.

Import a MySQL server database dump.

mysql -uroot -p database-name < database.sql


mysql -uroot -p new_db < db1.sql
Again, enter your user password at the prompt to restore the database dump you made earlier. Notice that the greater than has changed to a less than symbol as the flow of data has changed to going into the database.

Disable innodb in MySQL 5.5+

default-storage-engine myisam

Disable innodb in MySQL 5.4 and below