MySQL modifies the root user password

Source: Internet
Author: User

ArticleSource: http://www.centos.bz/2011/04/reset-mysql-root-password/

Follow these steps to reset the password of the MySQL database server. Step 1: Stop the MySQL server. Step 2: Use-Skip-grant-tables to select to start the mysqld process to cancel the Logon Request password prompt. Step 3: Use the root user to connect to the MySQL server. Step 4: set a new MySQL Root User Password. Step 5: exit and restart the MySQL server. The following are the specific commands for each step.

1. Stop the MySQL Service
    1. /Etc/init. d/MySQL stop

Output:
Stopping MySQL database server: mysqld.

2. Set the ignore password to start the MySQL server
    1. Mysqld_safe -- skip-grant-tables &

Output:
[1] 5988
Starting mysqld daemon with databases from/var/lib/MySQL
Mysqld_safe [6025]: started

3. Use the mysql client to connect to the MySQL server
    1. Mysql-u Root

Output:
Welcome to the MySQL monitor. commands end with; or G.
Your MySQL connection ID is 1 to server version: 4.1.15-Debian_1-log

Type 'help; 'or 'H' for help. Type 'C' to clear the buffer.

Mysql>

4. Set a new MySQL Root User Password
    1. Mysql> use MySQL;
    2. Mysql> Update user SET Password = PASSWORD ("new-root-Password") where user = 'root ';
    3. Mysql> flush privileges;
    4. Mysql> quit
5. Stop the MySQL server
    1. /Etc/init. d/MySQL stop

Output:
Stopping MySQL database server: mysqld
Stopping server from PID file/var/run/mysqld. PID
Mysqld_safe [6186]: ended

[1] + done mysqld_safe-Skip-grant-tables

6. Start and test the MySQL server.
    1. /Etc/init. d/MySQL start
    2. Mysql-u root-P

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.