Linuxmysql adds users, deletes users, and user permissions _ MySQL

Source: Internet
Author: User
Some basic commands: logon: mysql-uusername-p: show all databases: showdatabases; use a database: usedatabasename; show all tables of a database: showtables; exit: quit; some basic commands for deleting databases and data tables:

Logon:

Mysql-u username-p

Show all databases:

Show databases;

Use a database:

Use databasename;

Display All tables of a database:

Show tables;

Exit:

Quit;

Delete databases and data tables

Mysql> drop database name;

Mysql> drop table data table 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 logon ip address, user name, and password.

Authorize a User:
Format: grant permission on database. * to username @ login host identified by "password"; example: grant all privileges on testDB. * to test @ localhost identified by '123 ';
Then execute the command to refresh the permission: flush privileges;

Grant some permissions to a user:
Grant select, update on testDB. * to test @ localhost identified by '20140901 ';

Grant certain permissions to all databases of a user:
Grant select, delete, update, create, drop on *. * to test @ "%" identified by "1234 ";

Delete a user:
Delete FROM user Where User = 'test' and Host = 'localhost ';
Then refresh the permission;
Delete Account and permissions:> drop user username @ '% ';

> Drop user username @ localhost;

Change the password of a specified user

Use root to log on:
Mysql-u root-p
Run the following command:
Update mysql. user set password = password ('New password') where User = "test" and Host = "localhost ";
Refresh permission:
Flush privileges;
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.