How-to create a MySQL database and assign user privileges to it
NOTE: Please note that this is done in the Command Line Interface.
- First login to the mySql server using root.
mysql -uroot -pROOT_PASSWORD
Replace ROOT_PASSWORD with the password for the root user.
- Once logged in we create a new database called TEST_DB replace with your database name
create database TESTDB; Query OK, 1 row affected (0.00 sec)
- We grant access privileges to user MYUSER to connect to the mysql server from localhost using the password MYPASSWORD
grant usage on *.* to [email protected] identified by 'MYPASSWORD'; Query OK, 0 rows affected (0.00 sec)
- Now we grant all privileges to MYUSER on the database TESTDB
grant all privileges on TESTDB.* to [email protected] ; Query OK, 0 rows affected (0.00 sec)
- Type exit to log out
- Now you can login to TESTDB using user MYUSER and password MYPASSWORD
mysql -u MYUSER -p'MYPASSWORD' TESTDB