Create a database and associate it to a user - MySQL
Ndirangu Waweru
Posted on October 17, 2022
Login to your MySQL root
account (or any other account with admin privileges):
mysql -u root -p
Create the database you want your new user to be associated with:
CREATE DATABASE example_database;
Create the new user:
CREATE USER 'example_user'@'localhost' IDENTIFIED BY 'password';
Grant the new user access to the newly created database:
GRANT ALL ON example_database.* TO 'example_user'@'localhost';
Login to MySQL with your new user:
mysql -u example_user -p
Check the databases under the new user:
show databases;
Build something awesome!
💖 💪 🙅 🚩
Ndirangu Waweru
Posted on October 17, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.