Create and delete users in Mysql

Source: Internet
Author: User

Create and delete users in Mysql
1. Add a user (in two forms ):


A. mysql> grant all on *. * to yushan @ "%" identified by "123 ";
Mysql> flush privileges; (refresh the system permission table)
(The execution will be completed in mysql. insert a record to the user table. "all" indicates all permissions (including adding, deleting, modifying, and querying permissions ),*. * Indicates all databases. yushan indicates the username, 123 indicates the password, and % indicates all matched hosts. The preceding information can be specified, such as grant select and update on db. * to yushan @ localhost identified by '100 ";)


B. directly add a record to mysql. user


Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "yusuhan", password ("123 "));

Mysql> flush privileges;

In this way, a user named: yushan password: 123 (the password is encrypted) is created. However, the user has no permission because only three fields are added, you can also add permissions through grant:


Mysql> grant all on *. * to yushan @ localhost identified by '2017 ";
Mysql> flush privileges; (refresh the system permission table)

After adding a user, if you want to remotely log on to MySQL, you must keep up with the Host Ip address as follows:


[Root @ localhost ~] # Mysql-u yushan-p-h 192.168.59.123
Enter password: (Enter the password)

2. delete a user:


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

Mysql> flush privileges; (refresh the system permission table)

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.