MySQL command help

Command to create mysql user

CREATE USER 'username'@'localhost' IDENTIFIED by 'password';

Command to grant all privileges to a user to databases starting with any name

GRANT ALL PRIVILEGES ON database_.* TO 'username'@'localhost' IDENTIFIED BY 'password';

flush privileges;

The above two line command will make the user “username” to have all the privileges to add delete modify databases that starts with the name database_.

Command to dump mysql database

mysqldump -u [databaseusername] -p[password] databasename > databasebackup.sql

Command to restore mysql database

mysqldump -u [databaseusername] -p[password] databasebackup < databasename.sql

Command to dump all MySQL databases

mysqldump -u root -p(password) –all-databases > dumpfilename.sql

Command to grant privileges to mysql database starting with prefix

 GRANT ALL PRIVILEGES ON `databaseprefix_%`.* TO 'username'@'localhost'; 

Leave a Reply

Protected by WP Anti Spam