Linux to modify the use of MySQL (root password and modify the root login permissions

Source: Internet
Author: User
Tags mysql login root access

The modified users are listed as root.

First, know the original MYQL database root password;

①: Enter mysqladmin-u root-p password "New password" return in terminal command line, enter password: "Enter old password"
②: Log in to MySQL system changes, mysql-uroot-p Enter Password: "Enter the original password"

mysql> usemysql;

mysql> Update user set Password=password ("New password") where user= ' root '; "Password Note case"

Mysql> flush Privileges;

Mysql> exit;

You can then log in using the new password you just entered.

Second, do not know the original myql root password;
First, you must have root access to the operating system. If you do not have the root authority of the system, consider the root system before taking the following steps. Similar to Safe Mode login system.

The MySQL service needs to be stopped first, there are two cases, one can use service mysqld stop,

The other is /etc/init.d/mysqld stop

When prompted that MySQL has stopped after the next operation shutting down MySQL. Success!

In terminal command line input

Mysqld_safe--skip-grant-tables & "Log in to MySQL system"

Enter MySQL login mysql system

mysql> use mysql;

mysql> UPDATE user SET Password=password ("New password") WHERE user= ' root '; "Password Note case"

Mysql> flush Privileges;

Mysql> exit;

Restarting the MySQL service

This will set the new root password to succeed.

Third, modify the root login permissions

This is likely to happen when you modify the root password.

ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)

This is because the root login permissions are insufficient, the specific modification method is as follows

The MySQL service needs to be stopped first, there are two cases, one can use service mysqld stop,

The other is /etc/init.d/mysqld stop

When prompted that MySQL has stopped after the next operation shutting down MySQL. Success!

In terminal command line input

Mysqld_safe--skip-grant-tables & "Log in to MySQL system"

Enter MySQL login mysql system

Mysql>use MySQL;

Mysql>update User Set host = '% ' where user = ' root ';

Mysql>select host, user from user;

Mysql> flush Privileges;

Mysql> exit;

Then restart the MySQL service to do so.

Linux to modify the use of MySQL (root password and modify the root login permissions

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.