Web Developement
Now Reading
Setup New User from MySQL Command Line

Setup New User from MySQL Command Line

by Adrian RandallJanuary 24, 2016

This will help you create a new user from the command line and give them access to all databases within the MySQL Instance.

1. Login to MySQL using the current root name and password:
    mysql -u root -p 
You will then be prompted for the current root password.
2. Next create the new user and give them a password. In this case we’ll create a demo username and password but for actual setups use a secure username and password which is unique to the company. In our example ‘magentobase’ is the username and ‘MagentoBase01’ is the password.
    CREATE USER ‘magentobase’@’localhost’ IDENTIFIED BY ‘MagentoBase01’;
3. If you’re setting up shared hosting then make the username and password only allow access to the database it needs access to but if it’s dedicated I just give it root access so we can use the same one for a Staging and Production environment setup:
    Access To All Databases – GRANT ALL PRIVILEGES ON * . * TO ‘magentobase’@’localhost’;
    Access To Database called MyDatabase – GRANT ALL PRIVILEGES ON MyDatabase . * TO ‘magentobase’@’localhost’;
4. Now we just need to flush the settings so the new privileges are picked up and work:


About The Author
Adrian Randall
I'm a digital marketing specialist, love working on digital business and coding on just about anything. I'm the founder of Arcadian Digital and this site shares some of our knowledge and practices.

Leave a Response