Add users to MySQL

Source: Internet
Author: User

3. Add users:

(Note: Unlike the above, the following commands in the MySQL environment are followed by a semicolon as the command Terminator)

Format: grant select on database. * To username @ login host identified by "password"

 

First:

Add a user named "test1" with the password "ABC" so that he can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to MySQL, and then type the following command:

Grant select, insert, update, delete on *. * To test1 @ "%" identified by "ABC ";

 

However, the added users are very dangerous. If someone knows the password of test1, then, he can log on to your MySQL database on any computer on the Internet and do whatever he wants for your data. The solution is as follows:

First, add a user named "Test2" with the password "ABC" so that the user can only log on to localhost, you can also query, insert, modify, and delete the database mydb (localhost refers to the local host, that is, the host where the MySQL database is located), so that the user knows the password of Test2, he cannot directly renew data on the Internet either.

Mysql> grant select, insert, update, delete on book. * To Test2 @ localhost identified by "ABC ";

 

If you do not want Test2 to have a password, you can run another command to remove the password.

Mysql> grant select, insert, update, delete on book. * To Test2 @ localhost identified "";

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.