Tag Archives: mysql

useful mysql commands

Few things I repeatedly look up on the interwebs, keeping here for reference:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database1.* TO ‘yourusername’@’localhost’ IDENTIFIED BY ‘yourpassword’;

SHOW GRANTS FOR user@localhost;

SELECT * FROM mysql.user;

MySQL database dump & restore

Putting this here as I keep having to google it (paranoid that I’d do something wrong and mess up the db more than anything else) and keep finding crap results.

mysqldump -u [username] -p [database_name] > dump.sql
# it then prompts for the password

mysql -u [username] -p [database_name] < dump.sql
# it then prompts for the password