How to modify the mysql password and forget the mysql password

Source: Internet
Author: User

Modify the MySQL password:

Copy codeCode: mysqladmin-u root-p password 123456
Mysqladmin-u username-p old password New password

Forget the MySQL password:

Copy codeThe Code is as follows: chown-R mysql: mysql/var/lib/mysql
/Etc/init. d/mysql stop or kill-9 to kill the process.
[Root @ corshetlpro01 bin] # cd/usr/local/mysql/bin
./Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
[Root @ corshetlpro01 bin] # ps-ef | grep mysql
Root 26544 25356 0 00:00:00 pts/18/bin/sh./mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking
Mysql 26673 26544 0 00:00:00 pts/18/usr/local/mysql/libexec/mysqld -- basedir =/usr/local/mysql -- datadir =/var/lib/mysql -- user = mysql -- skip-grant-tables -- skip-networking -- log-error =/var/lib/mysql/corshetlpro01.err -- pid-file =/var/lib/mysql/corshetlpro01.pid -- socket = /tmp/mysql. sock -- Ports = 3306
Root 27223 25356 0 00:00:00 pts/18 grep mysql
./Mysql-u root
Mysql> use mysql;
Mysql> update user set password = password ('newpassword') where user = 'root ';
Mysql> flush privileges;
Mysql> quit
#/Etc/init. d/mysql restart
# Mysql-uroot-p
Enter password: <enter the new password newpassword>
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.