MySQL shortcuts

Quoting myself from my old blog:
Over the last decade, I have installed MySQL dozens of times on dozens of computers using several different operating systems. However, when the time comes that I need to do it again, I can never freaking remember how to do it quickly and easily.  ... I am aware that I have done this successfully many times, and I wish it could just "stay" done so that I do not have to expend this effort over and over. However, as I change jobs and change computers over time, it seems any optimization is unlikely.
Therefore below I repost commands I should have memorized years ago but I haven't.  So there!

MySQL privileges
GRANT ALL PRIVILEGES ON dbnam.tables TO 'username'@'whatev.edu or %' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

MySQL import
mysql -u username -p dbname < dbname.sql

MySQL export
mysqldump -u username -p databasename > /path/to/save/mydumpfile.sql

Start MySQL on OS X
sudo /usr/local/mysql/support-files/mysql.server start

Install MySQL on OS X
http://www.bos89.nl/install-mysql-on-mac-osx/

Update MySQL Root Password
version 5.7.6 and later:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPass';
version 5.7.5 and earlier:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newPass');

No comments:

Post a Comment

Translate