Linux environment MySQL new user and database and authorize

Source: Internet
Author: User
Tags create database

1. Log in to MySQL

#mysql-U root-p

2. New users

Insert into Mysql.user (Host,user,password) VALUES ("localhost", "xxx", Password ("* * *"));

Note: XXX is a new user name, * * * user password

3. After executing the sentence, you also need to refresh the permission table

Flush privileges;

4. Create a new database and give users permissions
Create Database dbtest;

All licenses:
Allow log on locally
Grant all privileges the dbtest.* to [e-mail protected] identified by "*";
Allow any host to log on
Grant all privileges on dbtest. To [e- mail protected] '% ' identified
by ';
Partial authorization:
Grant Select,update on dbtest.* to [e-mail protected] identified by "* * *";

5. Grant permissions, and then refresh the permissions table

Flush privileges;

6. Query for new results with SQL statements

Select User,host,password from Mysql.user;

7. Delete a user

Delete from user where user= ' xxx ';
Flush privileges;

8. Deleting a database

Drop database dbtest;

9. Change the password

Update Mysql.user set Password=password (' New password ') where user= ' xxx ' and host= ' localhost ';
Flush privileges;

Linux environment MySQL new user and database and authorize

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.