Change password and access restriction settings in MySQL database _ MySQL

Source: Internet
Author: User
MySQL is a real multi-user, multi-thread SQL database server. MySQL is implemented in a client server structure. it consists of a server daemon mysqld and many different client programs and libraries. MySQL is a real multi-user, multi-thread SQL database server. MySQL is implemented in a client/server structure. it consists of a server daemon mysqld and many different client programs and libraries. Because of its open source code and stability, and its perfect combination with the popular website programming language PHP, many websites now use it as a back-end database, making it widely used. In terms of security, each user must be given access restrictions on different databases to meet the requirements of different users. We will discuss it separately for your reference.

I. Summary of MySQL password change methods

The first thing to note is: Generally, you need to have the root permission in MySQL to change the mysql password. in this way, you cannot change the password unless you ask the administrator to help you modify the password.

Method 1

Using phpMyAdmin (a graphical MySql database management tool) is the simplest. you can directly use SQL statements to modify the user table of the mysql database, but do not forget to use the PASSWORD function to Insert the user using the Insert command, modify the user's use of the Update command and Delete the use of the Delete command. This section describes the user field of a data table.

Method 2

Use mysqladmin. Input:

Mysqladmin-u root-p oldpassword newpasswd after executing this command, you need to enter the original root password, so that the root password will be changed to newpasswd. Similarly, change the root in the command to your username, and you can change your password. Of course, if your mysqladmin cannot connect to mysql server, or you cannot execute mysqladmin, this method is invalid, and mysqladmin cannot clear the password.

The following methods are used at the mysql prompt and must have the root permission of mysql:

Method 3

Mysql "gt; insert into mysql. user (Host, User, Password) valueS ('%', 'system', PASSWORD ('manager'); mysql "gt; flush privileges. Specifically, this is to add a user with the username system and password manager. Be sure to use the PASSWORD function, and then use flush privileges for confirmation.

Method 4

Similar to method Sany, but the REPLACE statement is used.

Mysql "gt; replace into mysql. user (Host, User, Password) valueS ('%', 'system', PASSWORD ('manager'); mysql" gt; FLUSH PRIVILEGES

Method 5

Use the set password statement

Mysql "gt; set password for system @" quot; % "quot; = PASSWORD ('manager ');

You must also use the PASSWORD () function, but do not need to use flush privileges for confirmation.

Method 6

Use the GRANT... identified by statement to GRANT permissions.

Mysql "gt; grant usage on *. * TO system @" quot; % "quot; identified by 'manager ';

Here, the PASSWORD () function is unnecessary and you do not need to use flush privileges for confirmation.

Note: The PASSWORD () function is used to encrypt passwords and automatically interpret them in MySql.

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.