MySQL Create, delete user

Source: Internet
Author: User
Tags mysql create

1. Add a user (in two forms):


A.mysql> Grant All on * * to [e-mail protected] "%" identified by "123";
Mysql>flush privileges; (Refresh System Permissions table)
(After execution will insert a record in the Mysql.user table, all means all permissions (including add and delete changes and other permissions), * * For all databases, Yushan for the added user name, 123 for the password,% for all hosts matching, the above information can be specified such as Grant Select, Update on db.* to [e-mail protected] identified by ' 123 ';)


B. Add a record directly to Mysql.user


mysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("localhost", "Yusuhan", Password ("123"));

Mysql>flush privileges;

This creates a user named: Yushan password: 123 (password is encrypted), but does not have permissions because only three fields are added, and permissions can be added through grant:


Mysql>grant all on * * to [e-mail protected] identified by ' 123 ";
Mysql>flush privileges; (Refresh system Permissions table)


Add user if you want to log in to MySQL remotely, you must follow the host IP as follows:


[Email protected] ~]# mysql-u yushan-p-H 192.168.59.123
Enter Password: (enter password)

2. Delete the User:


Mysql>delete from mysql.user where user = ' Yushan ';

Mysql>flush privileges; (Refresh System Permissions table)

MySQL Create, delete user

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.