Mysql Basic Life

Source: Internet
Author: User

1. Change the password

Without knowing the original password: the process of shutting down MySQL

Enter "Mysqld_safe--skip-grant-tables &" command to enter MySQL Safe mode without password.

Then you can use a blank password like mysql-u root

show databases; View current database

Use tables; View the current table

    Update user set password= ("New password") where user= ' root ' can change the password.

Enter "flush privileges;" Update permissions.

Then restart the service.

2. Create a new user

After entering MySQL, use MySQL.

Create user ' sz ' @ ' localhost ' indentified by ' 123456 ' creates a username of sz password 123456 login locally

Flush Privilegs Update Permissions

3. Give MySQL user permissions

  

 All: All available permissions

Create: Creating libraries, tables, and indexes

Lock_tables: Lock Table

Alter: Modify Table

Delete: Deleting a table

Insert: Inserting a table or column

SELECT: Retrieving data for a table or column

Create_view: Creating a View

Show_databases: List Database

Drop: Delete libraries, tables, and views

 Run the command to give the user permission

Grant create on Mysql.user to ' sz ' @ ' localhost ';

Cases:

Full permissions granted to the user

Show grant for ' sz ' @ ' localhost ';

Remove all user rights

Remove permission on the table name for ' sz ' @ ' localhost ';

Last refresh permission flush Privilegs;

Create a user who can connect to the server from anywhere.

Grant all privileges on * * to [e-mail protected] identified by ' something ' with

Root can log on outside

Use MySQL;

Grant all privileges on * * to [email protected] '% ' identified by ' root ' with GRANT OPTION;

Flush privileges;

2. Basic commands

DESC user; View all information in a table

  

Mysql Basic Life

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.