After MySQL is installed on VPS, the default user is root @ localhost. The simplest way to add a new MySQL User is:
Execute the following statement in phpmyadmin (add points at the end of the statement; no ):
Grant all privileges on DBNAME. * to USERNAME @ localhost identified by 'password'
Flush privileges
Of course, run in SSH
Mysql-uroot-p
Then, you can enter the preceding SQL statement, with the same effect.
Explanation:
This will add a new user with the USERNAME and PASSWORD. This user has the permission to modify and read the database DBNAME.
Add an idea to clarify how to add users
1. Create a user
Mysql-u root-p
Enter password
Then go to mysql command line management
Insert into mysql. user (Host, User, Password) values ('localhost', 'admin', password ('123 '));
// Refresh the system permission list
Mysql> flush privileges;
2. Create a database
Create database newdatabase;
3. Authorize the user
Mysql> grant all privileges on newdatabase. * to admin @ localhost identified by '123 ';
Mysql> flush privileges;
You can also grant specific permissions to this user.
Grant select, insert, update, delete on newdatabase. * to admin @ localhost identified by '123 ';
A total of 14 permissions are available: select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process, and file.
Mysql> grant all privileges on vtdc. * to joe@10.163.225.87 identified by '2017 & prime ;;
Assign the user joe from 10.163.225.87 the permission to perform all operations on all tables in the database vtdc and set the password to 123.
Mysql> grant all privileges on *. * to joe@10.163.225.87 identified by '2017 & prime ;;
Assign the user joe from 10.163.225.87 the permission to perform all operations on all tables in all databases and set the password to 123.
Mysql> grant all privileges on *. * to joe @ localhost identified by '2017 & prime ;;
Grant the local user joe the permission to perform all operations on all tables in all databases and set the password to 123.