14th March 2011

MySQL Reference

Set password if old password is empty or known:

mysqladmin -u root password "secret"
mysqladmin -u root -p'oldpassword' password "secret"

Set password using SQL:

use mysql;
update user set password=PASSWORD("secret") where User='roe';
flush privileges;

Start MySQL without any access control to reset the root password:

mysqld_safe --skip-grant-tables

Create database and user with (insecure) full access privileges:

mysqladmin -u root create foo
mysql foo -u root -e"GRANT ALL ON foo.* TO fooadm@localhost IDENTIFIED BY 'secret'"

Delete database:

mysqladmin -u root drop foo

Back to Knowledge Base.