Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql forgot root password solution (linux)

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Force shutdown of mysql

# pkill mysql

two。 Add to Profil

[mysqld]

Skip-grant-tables

3. Restart mysql

Click (here) to collapse or open

# / usr/local/mysql/bin/mysqld_safe-- defaults-file=/etc/my.cnf-- user=mysql & [1] 29335 [root@mysql5 logs] # 180310 21:00:11 mysqld_safe Logging to'/ home/mysql3306/logs/mysql-error.log'.180310 21:00:11 mysqld_safe Starting mysqld daemon with databases from / home/mysql3306/mysql3306

4. Login without password

# / usr/local/mysql/bin/mysql-S / tmp/mysql.sock

5. Reset root password

Click (here) to collapse or open

Mysql > update mysql.user set password=password ('root') where user='root';Query OK, 2 rows affected (0.03 sec) Rows matched: 4 Changed: 2 Warnings: 0mysql > flush privileges;Query OK, 0 rows affected (0.02 sec)

6. Restart mysql

# pkill mysql

Log skip-grant-tables out of the configuration file

# / usr/local/mysql/bin/mysqld_safe-defaults-file=/etc/my.cnf-user=mysql &

7. Verification

# / usr/local/mysql/bin/mysql-S / tmp/mysql.sock-uroot-p

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report