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

Linux/Centos resets the Mysql root user password

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

Share

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

Sometimes you may forget your root password for MySQL. Here's how to reset your MySQL root password.

Manual modification

1. Stop the MySQL service

Execute: / etc/init.d/mysql stop, it doesn't have to be / etc/init.d/mysql or / etc/init.d/mysqld on your machine.

Anyway, if you stop the database, you can also use kill to kill the process number ps-ef | grep mysql and then kill-9 mysql process number

2. Skip verification and start MySQL

/ usr/local/mysql/bin/mysqld_safe-- skip-grant-tables > / dev/null 2 > & 1 &

Note: if the location of the mysqld_safe is different from the above, you can use the find command to find it if it is not clear.

Find /-name mysqld_safe

3. Reset password

Then execute: mysql-u root mysql

At the mysql prompt, enter: update user set password = Password ('password to be set') where User = 'root'

After enter, execute: flush privileges; refreshes the tables related to the permissions of the MySQL system. Execute again: exit; exits.

4. Restart MySQL

Kill the MySQL process: killall mysqld

Start MySQL:/etc/init.d/mysql start

So MySQL's password is reset.

If you are interested, please scan the QR code below for more details for free

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