MySQL CLI Notes

I have a hard time remembering this stuff, I'm spoiled by GUI tools. For anyone who needs it I posted some mysql cli stuff here. Nothing new or earth shattering, just notes for the lazy.

-------------------------------------------------------------------------------------

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

GRANT SELECT ON database.* TO 'user'@'%' IDENTIFIED BY 'password'

SET PASSWORD FOR 'username'@'%' = OLD_PASSWORD('password');

mysqldump -u USER -pPASSWORD DATABASE > filename.sql

mysqldump --user="user" --password="pass" --opt --compact --quick --verbose --host="server.fqdn" --databases MyFavDB --result-file=/root/outfile.sql

mysqldump --opt --extended-insert --single-transaction --create-options --default-character-set=utf8 --user="root" --password="*****" --host="server.fqdn" --databases dbname > "/data/backup.sql"

mysql dbname < filename.sql


If you upgrade the RHEL/Fedora bundled version MySql with the rpmp version from MySql.com you will find the service will fail to start. To get MySQL running again via the default init scripts do the following:


  1. Rem out the line in /etc/my.conf that was setting basedir to /var/lib. As seen below:

    user=mysql
    #basedir=/var/lib

  2. Create the directory "/var/run/mysqld" if it does not exist. Then chown that directory to mysql.mysql as below...

    mkdir /var/run/mysqld
    chown mysql.mysql /var/run/mysqld

  3. Start the service..

    service mysql start