Notes about MySQL

  • Syntax to execute a series of commands contained in a text file:
mysql [-p -u myuser] mydatabase < sql2execute.txt
  • Subqueries are available from version 4.1 onwards.
  • Add additional users (power-mode):
    GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost' IDENTIFIED BY 'newuserpasswd' WITH GRANT OPTION;
  • To change the password type:
    /usr/bin/mysqladmin -u root -p password <new-password>
You will be prompted for the old password
  • To write the output of a query/sql to a file use:
    mysql -u <youruserid> -p --tee output.txt
Omit "-p" if you didn't set a password.
  • To grant all rights for a specific DB to a user:
    grant all on <dbname>.* to <username>@localhost identified by '<userpassword>';