1. Create user
CREATE user test@localhostby'123456'; #建立的用户名为test, users with a password of 123, #localhost限制在固定地址localhost登陆
#创建远程连接用户 Create User by ' 123456 ';
2. Authorization
GRANT Privileges on to ' username '@'host'
Description: Privileges-user's operation permissions, such as SELECT, INSERT, UPDATE, etc. Use all if you want to grant the permission;
DatabaseName-database name, tablename-table name, if you want to grant the user permission to operate on all databases and tables, the * representation is available *, such as *. *
For example:
grant insert , delete , update , select on test. * to test " @" localhost " ;flush ;
Grant All Privileges on *. * to ' test2 '@'%'by'123456'with Grantoption;
All means to accept all actions, such as select,insert,delete ...;
*. * represents all tables below all libraries;
% on behalf of this user is allowed to log in from anywhere;
For security periods, this% can be replaced with the IP address you allow;
Then refresh the MySQL user Rights related table;
privileges ;
3. Setting and changing user passwords
SETPASSWORD for 'username'@'Host' =PASSWORD ('NewPassword') #如果是当前登陆用户SETPASSWORD=PASSWORD ("NewPassword"); #例如:SETPASSWORD for 'test2'@'%' =PASSWORD ("123456");UpdateMysql.User SetPassword=Password'New Password')where User="Phplamp" andHost="LocalHost";
update MySQL. User set Password=password (' new password 'whereUser= and Host="localhost";
Open MySQL configuration file
Bind-address = 127.0.0.1
Here MySQL default binding local IP, do not accept other sources, such as to remotely connect to the database, comment out this, restart MySQL;
Delete User
Delete from User where User = ' Test ' and Host='localhost';
MySQL create user and authorization, change password