The management of MySQL users under Linux

Source: Internet
Author: User
Tags flush log mysql in linux

Since the installation of MySQL in Redhat Enterprise 5, this time to practice the management of MySQL users;

First, the root user password maintenance:

Since MySQL is installed, MySQL will automatically provide a root user without a password, and set the password to root for security purposes:

#mysqladmin-U root password 123 (123 is a password, can also be written as: ' 123 ' or ' 123 ');

You can not enter MySQL directly after setting the password, you must follow some parameters, as follows:

[Root@localhost ~]# mysql-u root-p (-u followed by login username,-p prompts for password login)

Enter Password: (enter password)

Modify Password:

[root@localhost ~] #mysqladmin-u root-p password 123456 (password followed by the new password to be updated)

Enter Password: (input original password, enter can)

Ii. additions and deletions of other users:

Log in as root, there is a mysql.user table in MySQL is the information table that stores all the users in MySQL, so you can add and remove users by directly adding records to delete this table.

1. Add users (in two forms):

A.mysql> Grant all on *.* to yushan@ "%" identified by "123";

Mysql>flush privileges; (Refresh system Permission table)

(After the execution will insert a record in the Mysql.user table, all to indicate all permissions (including additions and deletions), *.* means all databases, Yushan for the added username, 123 for the password,% for all matching hosts, the above information can be specified as Grant SELECT, Update on db.* to yushan@localhost 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, you can add permissions through grant:

Mysql>grant all on *.* to yushan@localhost identified by ' 123 ';

Mysql>flush privileges; (Refresh system Permission table)

(This seems a bit verbose.) Directly with Grant soon)

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

[Root@localhost ~]# mysql-u yushan-p-H 192.168.59.123

Enter Password: (enter password)

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.