This tutorial will help you set up a new database with a new user that has access to a specific database or all databases.
Note: Make sure you change new_mysql_database
, new_mysql_user
and new_mysql_password
with something of your own and create a strong password.
Use the root user ONLY for administration purposes. By using the root user on production, you risk of having a system-wide security hole.
Note: This command must be run as root, hence the sudo
in front of it.
sudo mysql -u root -p
and press ENTER
CREATE DATABASE new_mysql_database;
CREATE USER 'new_mysql_user'@'localhost' IDENTIFIED BY 'new_mysql_password';
GRANT ALL PRIVILEGES ON new_mysql_database.* TO 'new_mysql_user'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'new_mysql_user'@'localhost';
GRANT USAGE ON *.* TO 'new_mysql_user'@'localhost';
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'new_mysql_user'@'localhost';
Resources: