Linux MySQL add users, delete users, and user permissions

Source: Internet
Author: User

Some basic commands:

Login:

Mysql-u username-p

To display all databases:

show databases;

Use a database:

Use DatabaseName;

Show all tables for a database:

Show tables;

Exit:

Quit

deleting databases and data tables

Mysql>drop database name;

Mysql>drop table Data Sheet name;

User-Related: View all users:
SELECT DISTINCT CONCAT (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;

New User:
Insert into Mysql.user (Host,user,password) VALUES ("localhost", "Test", Password ("1234"));
The last three parameters are login IP, username, password

To authorize a user:
Format: Grant permissions on database. * To username @ Login host identified by "password"; Example: Grant all privileges on testdb.* to [email protected] identified by ' 1234 ';
Then you need to execute the command to refresh the permissions: Flush privileges;

To grant a user partial permissions:
Grant Select,update on testdb.* to [e-mail protected] identified by ' 1234 ';

Grant certain permissions to a user for all databases:
Grant Select,delete,update,create,drop on * * to [e-mail protected] "%" identified by "1234";

To delete a user:
Delete from user Where user= ' test ' and host= ' localhost ';
then refresh the permissions;
Delete account and permissions: >drop user username @ '% ';

>drop user username @ localhost;

Modify the specified user password

Log in with Root:
Mysql-u root-p
Execute command:
Update Mysql.user set Password=password (' New password ') where user= "test" and host= "localhost";
Refresh permissions:
Flush privileges;

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux MySQL add users, delete users, and user permissions

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.