MySQL Cheat Sheet
Revision as of 10:41, 26 March 2018 by Michael.mast (talk | contribs)
Contents
View users
select host, user, password from mysql.user;
Remove history
(this is kept in your home directory)
rm -rf ~/.mysql_history
Remove user
drop user <username>@<host>;
Remove database
drop database <databasename>;
Grant privileges
grant all on <database>.<table> to <user>@<host> identified by '<password>'; grant all on test.* to 'michael'@'172.17.0.34' identified by 'mypassword';
Show granted privileges
SHOW GRANTS FOR 'root'@'localhost';
Delete rows older than certain date
DELETE FROM `table` WHERE `column` < DATE_SUB(NOW(), INTERVAL 3 MONTH);