In this article we mainly explain the knowledge of adding new users to the MySQL database. So how to add a new user to the MySQL database? The editor has not done it in the command mode. Now it is done through phpmyadmin. Let’s take a look. The tutorial compiled by the editor hopes to help everyone.
After installing MySQL on the VPS, the default user is only root@localhost. The easiest way to add a new MySQL user is:
Execute the following statement in phpmyadmin (add at the end of the statement (; sign):
grant all privileges on DBNAME.* to USERNAME@localhost identified by 'PASSWORD' flush privileges
Of course, you can also enter the above sql statement after running
mysql -uroot -p
in SSH, and the effect will be the same.
The explanation is as follows:
This will add a new user. The user name is USERNAME and the password is PASSWORD. This user has modification, read and other permissions in the DBNAME database.
Add an article to clarify the method of adding users
1 Create a new user
mysql -u root -p
Input Enter the mysql command line management after password
insert into mysql.user(Host,User,Password) values('localhost','admin',password('123456'));
//Refresh the system permission table
mysql> flush privileges;
2 Create database
create database newdatabase;
3 Authorize the user
mysql>grant all privileges on newdatabase.* to admin@localhost identified by '123456'; mysql>flush privileges;
You can also grant specific permissions to the user
grant select, insert,update,delete on newdatabase.* to admin@localhost identified by '123456';
A total of 14 permissions select,insert,update,delete,create,drop,index,alter, grant,references,reload,shutdown,process,file
mysql>grant all privileges on vtdc.* to joe@10.163.225.87 identified by '123′;
Assigned to user joe from 10.163.225.87 You can 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 '123′;
Assign user joe from 10.163.225.87 to perform all operations on all tables in all databases permissions and set the password to 123.
mysql>grant all privileges on *.* to joe@localhost identified by '123′;
Assign the local user joe the permissions to perform all operations on all tables in all databases, and set The password is 123.
Related recommendations:
Detailed explanation of examples of adding new user permissions in MySQL
Add new users to MySQL configuration under Linux
How to add new users to your MySQL database
The above is the detailed content of Detailed explanation of adding new users to MySQL database. For more information, please follow other related articles on the PHP Chinese website!