Eddie Hinkle


Create a new mysql database and user

I have found myself installing a lot of open source projects lately that are based on the PHP-Mysql stack. For each project, I generally want to create a new mysql database and user. Every time I install a new project I end up googling around the internet looking for the instructions again, so this is more for me than you, but you are welcome to use these notes as well.

The instructions come from debuntu.org.

First I need to log into mysql's CLI:

  1. mysql -u root -p

Then, I need to create the database named 'db1':

  1. create database db1;

Next, we make a user called 'user1' with password 'pass1':

  1. grant usage on *.* to user1@localhost identified by 'pass1';

Finally, we grant privileges to our 'user1':

  1. grant all privileges on db1.* to user1@localhost;

Voila! Now, you have a new user with their own database in MySQL.

Please note: This site is in an active redesign. Some things might be a little off 🧐