Linux Reset mysql Password

Source: Internet
Author: User

1. Stop the MySQL program

[email protected] ~]# service mysqld stopstopping mysqld:                                           [  OK  ]

2. Open the MySQL configuration file

[Email protected] ~]# VIM/ETC/MY.CNF
Search Mysqlld /mysqld
[Mysqld] #下一行添加
Skip-grant-tables #忽略MySQL权限问题, log in directly

3. Turn on MySQL service

[[Email protected] ~]# service mysqld start

4. No password directly into MySQL

[Email protected] ~]# Mysqlwelcome to the MySQL Monitor.  Commands End With; or \g.your MySQL connection ID is 2Server version:5.1.73-log Source distributioncopyright (c), +, Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

5. Use the MySQL table to change the password

mysql> use MySQL Database changedmysql> Update user set Password=password ("123") where user= "root"; #密码修改为123Query OK, 3 rows A Ffected (0.00 sec) Rows matched:3  changed:3  warnings:0

6. Refresh Permissions

mysql> flush Privileges; Query OK, 0 rows Affected (0.00 sec)

7. Kill all Mysqld processes

[[email protected] ~]# killall mysqld[[email protected] ~]# ps-ef|grep mysqldroot      53342  45198  0 20:57 pts/6< c3/>00:00:00 grep mysqld

8. Turn on mysqld service

[[Email protected] ~]# service mysqld startstarting mysqld:                                           [  OK  ]

9. Test into MySQL

[Email protected] ~]# mysql-u root-penter password:welcome to the MySQL monitor.  Commands End With; or \g.your MySQL connection ID is 2Server version:5.1.73-log Source distributioncopyright (c), +, Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql>

Linux Reset mysql Password

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.