Create a MySQL database and user
These are the basic steps to create a new database and user for your applications:
Create a new database:
mysql> create database DATABASE_NAME; Query OK, 1 row affected (0.00 sec)
Create a new user (only with local access) and grant privileges to this user on the new database:
mysql> grant all privileges on DATABASE_NAME.* TO 'USER_NAME'@'localhost' identified by 'PASSWORD'; Query OK, 1 row affected (0.00 sec)
Create a new user (with remote access) and grant privileges to this user on the new database:
mysql> grant all privileges on DATABASE_NAME.* TO 'USER_NAME'@'%' identified by 'PASSWORD'; Query OK, 1 row affected (0.00 sec)
After modifying the MySQL grant tables, execute the following command in order to apply the changes:
mysql> flush privileges; Query OK, 1 row affected (0.00 sec)
Some applications require specific privileges in the database. Check the MySQL official getting started guide.