How to add an authorized user command in MySQL

Source: Internet
Author: User

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

 
 
  1. MySQL> mysql> insert into MySQL.user(Host,User,Password,ssl_cipher,x509_issuer,x509_sub   
  2. ject) values("localhost","pppadmin",password("passwd"),'','','');  

In this way, a user named: phplamp password: 1234 is created.

Then log on.

 
 
  1. MySQL>exit;   
  2. @>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)

 
 
  1. MySQL>create database phplampDB;  

Authorize the phplamp user to have all the permissions of the phplamp database.

 
 
  1. >grant all privileges on phplampDB.* to phplamp@localhost identified by '1234';  

Refresh system permission list

 
 
  1. MySQL>flush privileges;  

MySQL add authorization> other operations

/*

If you want to assign some permissions to a user, you can write as follows:

 
 
  1. MySQL>grant select,update on phplampDB.* to phplamp@localhost identified by '1234';  

Refresh the system permission table.

 
 
  1. MySQL>flush privileges;  

*/

3. delete a user.

@> MySQL-u root-p

@> Password

 
 
  1. MySQL>Delete FROM user Where User="phplamp" and Host="localhost";   
  2. MySQL>flush privileges;  

Delete a user's database

 
 
  1. MySQL>drop database phplampDB;  

4. Modify the password of the specified user.

@> MySQL-u root-p

@> Password

 
 
  1. MySQL> update MySQL. user set passwordpassword = password ('new password') where User = "phplamp" and Host = "localhost ";
  2. MySQL> flush privileges;

5. list all databases

 
 
  1. MySQL>show database;  

6. Switch the database

MySQL> use 'database name ';

7. list all tables

 
 
  1. MySQL>show tables;  

8. display the data table structure

 
 
  1. MySQL> describe table name;

9. Delete databases and data tables

 
 
  1. MySQL> drop database name;

MySQL> drop table data table name; Tag: MySQL add authorization command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.