New, authorize, delete, password modification in the WIN command prompt
First of all, we must declare: Under normal circumstances, to modify MySQL password and authorization, it is necessary to have root privileges in mysql.
Note: This operation is in the WIN command prompt, and phpMyAdmin is also applicable.
User: phplamp User database: phplampDB
1.New user
//Log in to MYSQL
@>mysql-u root-p
@>password
//create user
mysql> insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234"));
//Refresh the system privilege table
mysql>flush privileges;
This creates a name It is: phplamp password is: 1234 user.
Then log in.
mysql>exit;
@>mysql-u phplamp-p
@>Enter the password
mysql>login successful
2.Authorize the user
If you want to allow the user myuser to connect to the mysql server from the host whose ip is 192.168.1.6, and use mypassword as the password
GRANTALL PRIVILEGES ON *.* TO'myuser'@' 192.168.1.3' IDENTIFIED BY'mypassword' WITHGRANT OPTION;
FLUSH PRIVILEGES;
3.Delete user
@>mysql-u root-p
@>password
mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";
mysql>flush privileges;
//Delete user's database
mysql>drop database phplampDB;
4.Modify the specified user password
@>mysql-u root-p
@>password
mysql>update mysql.user set password=password('new password') where User="phplamp" and Host="localhost";
mysql>flush privileges;
Note: This operation is in the WIN command prompt, and phpMyAdmin is also applicable.
User: phplamp User database: phplampDB
1.New user
//Log in to MYSQL
@>mysql-u root-p
@>password
//create user
mysql> insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234"));
//Refresh the system privilege table
mysql>flush privileges;
This creates a name It is: phplamp password is: 1234 user.
Then log in.
mysql>exit;
@>mysql-u phplamp-p
@>Enter the password
mysql>login successful
2.Authorize the user
If you want to allow the user myuser to connect to the mysql server from the host whose ip is 192.168.1.6, and use mypassword as the password
GRANTALL PRIVILEGES ON *.* TO'myuser'@' 192.168.1.3' IDENTIFIED BY'mypassword' WITHGRANT OPTION;
FLUSH PRIVILEGES;
3.Delete user
@>mysql-u root-p
@>password
mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";
mysql>flush privileges;
//Delete user's database
mysql>drop database phplampDB;
4.Modify the specified user password
@>mysql-u root-p
@>password
mysql>update mysql.user set password=password('new password') where User="phplamp" and Host="localhost";
mysql>flush privileges;
0 Comments