Today we are going to discuss with you how to add user commands for MySQL authorization. I saw the MySQL authorization USER command information on the relevant website two days ago, let's share it with you. I hope it will help you in this regard.
1. Create a user.
Log on to MySQL
@> MySQL-u root-p
@> Password
Create user
- MySQL> mysql> insert into MySQL.user(Host,User,Password,ssl_cipher,x509_issuer,x509_sub
- ject) values("localhost","pppadmin",password("passwd"),'','','');
In this way, a user named: phplamp password: 1234 is created.
Then log on.
- MySQL>exit;
- @>MySQL -u phplamp -p
@> Enter the password
MySQL> logon successful
2. Authorize the user.
Log on to MySQL and grant the ROOT permission ). I log on as ROOT.
@> MySQL-u root-p
@> Password
First, create a database (phplampDB) for the user)
- MySQL>create database phplampDB;
Authorize the phplamp user to have all the permissions of the phplamp database.
- >grant all privileges on phplampDB.* to phplamp@localhost identified by '1234';
Refresh system permission list
- MySQL>flush privileges;
MySQL add authorization> other operations
/*
If you want to assign some permissions to a user, you can write as follows:
- MySQL>grant select,update on phplampDB.* to phplamp@localhost identified by '1234';
Refresh the system permission table.
- MySQL>flush privileges;
*/
3. delete a user.
@> MySQL-u root-p
@> Password
- MySQL>Delete FROM user Where User="phplamp" and Host="localhost";
- MySQL>flush privileges;
Delete a user's database
- MySQL>drop database phplampDB;
4. Modify the password of the specified user.
@> MySQL-u root-p
@> Password
- MySQL> update MySQL. user set passwordpassword = password ('new password') where User = "phplamp" and Host = "localhost ";
- MySQL> flush privileges;
5. list all databases
- MySQL>show database;
6. Switch the database
MySQL> use 'database name ';
7. list all tables
- MySQL>show tables;
8. display the data table structure
- MySQL> describe table name;
9. Delete databases and data tables
- MySQL> drop database name;
MySQL> drop table data table name; Tag: MySQL add authorization command