create database and new user in mysql with ssh

I keep forgetting how to do this. So, I will log it here once and for all:

Log into mysql:

mysql -u root -p

Create a database:

create database name_of_database;

Create a new user:


Give new user all the priviliges:


If you want to give the new user permission only for one database then the command is:

GRANT ALL PRIVILEGES ON name_of_database.* TO 'newuser'@'localhost';

Reload Mysql:


To change the password of the user:

mysqladmin -u root -p'oldpassword' password newpassword

You May Also Like

Leave a Reply
