MySQL Common commands

Source: Internet
Author: User

Note: The password field of the MySQL5.7 Mysql.user is to be used authentication_string

- -P

Create User: MySQL > Insert  into MySQL. User (Host,User

authorizing a user
Authorization format:GrantPermissions onDatabase.* toUser name@ Login HostIdentified by"Password";
Authorize the test user to have all permissions for the TestDB database (all permissions for a database): MySQL>Grant All Privileges onTestDB.* toTest@localhostIdentified by '123'; Format:GrantPermissions onDatabase.* toUser name@ Login HostIdentified by"Password"; If you want to specify partial permissions to a user, you can write this: MySQL>Grant Select,Update onTestDB.* toTest@localhostIdentified by '123'; Authorization test user has some permissions for all databases: MySQL>Grant Select,Delete,Update,Create,Drop on *.* to[Email protected] "%"Identified by"123"; MySQL>FlushPrivileges;//Refresh System Permissions Table

Note:@ "%" indicates authorization for all non-local hosts, excluding localhost.

Delete user MySQL>Delete  from User Where User='Test'  andHost='localhost'; MySQL>FlushPrivileges; MySQL>Drop DatabaseTestDB;//Delete User's database Delete account and permissions:>Drop UserUser name @'%'; >Drop UserUser name @ localhost;

Modify the specified user password  mysql>update MySQL. User set Password=password (' new password 'whereUser=    and Host="localhost";  MySQL>privileges;

list all databases MySQL > database;

switch Database MySQL >  Use ' Database name ';

list all tables MySQL >Show Tables;

Show data table structure MySQL >describe table name;

deleting databases and data tables MySQL > Drop Database  database name; MySQL>droptable data table name;

query version number MySQL >

MySQL Common commands

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.