MySQL Common operations

Source: Internet
Author: User

1. New Users

The code is as follows:
Mysql>insert into Mysql.user (Host,user,password) VALUES ("localhost", "Lionbule", Password ("hello1234"));
Mysql>flush privileges;

2. Modify User Password

The code is as follows:
Mysql>update Mysql.user Set Password=password (' New password ') where user= "Lionbule" and host= "localhost";
Mysql>flush privileges;

3. Delete a user

The code is as follows:
Mysql>delete from user WHERE user= "lionbule" and host= "localhost";
Mysql>flush privileges;

4. Permission Assignment

4.1. Grant Usage
Grant permissions on the database. * to User name @ ' login host ' identified by ' password '

The code is as follows:
Permissions:
General Summary, All/alter/create/drop/select/update/delete
Database:
*. * represents all tables for all libraries
Test.* represents all tables of the test library
Test.test_table represents the Test_table table for the test library
User name:
MySQL account name
Login Host:
Allow client IP to log in to MySQL server
'% ' means all IP
' localhost ' indicates that the machine
' 192.168.10.2 ' specific IP
Password:
Login password for Account

4.2 Examples

The code is as follows:
Mysql>grant all on test.* to [e-mail protected] '% ' identified by ' hello1234 ';
Mysql>flush privileges;

The new password for ' hello234 ' user Lionbule has all the permissions on the test library and does not restrict the Lionbule user's login IP.

4.3 precautions

Grant overwrites some of the user's information with the INSERT and update execution functions.

MySQL Common operations

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.