MySQL password forgot how to handle

Source: Internet
Author: User

If you forget the password for MySQL
1. Turn off the MySQL service
[[Email protected] ~]# service mysqld stop
2. Modify the service startup script, add--skip-grant-tables--skip-networking field skip authorization table and network

[Email protected] ~]# Vim/etc/init.d/mysqld

Case ' $mode ' in
' Start ')
# Start Daemon

# Safeguard (relative paths, core dumps ...)
CD $basedir

Echo $echo _n "Starting MySQL"
If Test-x $bindir/mysqld_safe
Then
# Give extra arguments to mysqld with the my.cnf file. This script
# May is overwritten at next upgrade.
$bindir/mysqld_safe--skip-grant-tables--skip-networking--datadir= "$datadir"--pid-file= "$mysqld _pid_file_path
"$other _args >/dev/null 2>&1 &
Wait_for_pid created "$!" "$mysqld _pid_file_path"; Return_value=$?

3. Start the service, connect MySQL, no need to enter the password
4. Change the root password, prompt to skip the authorization form cannot change the password, so you can only change the file
mysql> SET PASSWORD for ' root ' @ ' localhost ' =password (' 123456 ');
ERROR 1290 (HY000): The MySQL server is running with the--skip-grant-tables option so it cannot execute this statement

mysql> UPDATE user SET Password=password (' 123456 ') WHERE user= ' root ';
Query OK, 3 Rows Affected (0.00 sec)

5. After the password change is complete, turn off the MySQL service, modify the MySQL startup script, start the MySQL service
6. The client can log in to MySQL using the new password.

This article from "Plum blossom fragrance from bitter cold" blog, please be sure to keep this source http://wangjunkang.blog.51cto.com/8809812/1586081

MySQL password forgot how to handle

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.