17
Feb
2019

MySQL Linux Commands

List of useful MySQL commands for Linux.

Create a MySQL database

mysqladmin -u USERNAME -p create DATABASENAME

Export a MySQL database

mysqldump -u USERNAME -p DATABASENAME > EXPORTFILENAME.sql

Restore a MySQL database

mysql -u USERNAME -p DATABASENAME < DATABASEFILENAME.sql

Backup multiple databases at the same time

mysqldump --databases DATABASEONE DATABASETWO > DATABASEFILENAME.sql

Backup all databases

mysqldump --all-databases > DATABASEFILENAME.sql

Restore a single database from dump of all databases

mysql --one-database DATABASENAME < DATABASEFILENAME.sql

Set MySQL root password

mysqladmin -u root password PASSWORD

Change MySQL root password

mysqladmin -u root -pOLDPASSWORD password NEWPASSWORD
Share