Get the App
SLTechnology News&Howtos  ›  Database  › 

What if I forget my mysql password?

Shulou Source: shulou.com Published: 2022-06-01 20:15:36 11月15日 Update

The following is mainly to bring you forget the mysql password how to do, I hope that these words can bring you practical use, which is also the main purpose of my editing this article. All right, don't talk too much nonsense, let's just read the following.

Centos system

1] mysql5.6.x environment

Centos6.x shuts down mysql

# / etc/init.d/mysql stop

Centos7.x shuts down mysql

# systemctl stop mysqld

# mysqld_safe-user=mysql-skip-grant-tables-skip-networking &

# mysql-u root 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:

Mysql >

2] mysql5.7.x environment

# vim / etc/my.cnf

[mysqld]

Skip-grant-tables

: wq! # Save exit

/ / log in to the database

# mysql-uroot-p

> UPDATE user SET Password=PASSWORD ("userpasswd") where user= "username"

> flush privileges

> quit

/ / comment out the skip-grant-tables line of / etc/my.cnf

/ / restart the service

# systemctl restrt mysqld

At this point, you can log in successfully!

For the above about how to forget the mysql password, we do not think it is very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

Tags: Password what to do the following text content environment login success reality nonsense data database text more comments usefulness purpose article system industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL vpn MariaDB Shulou Technology