linux and mac Installation mysql Forgot Password Solution
- 2021-09-16 08:28:04
- OfStack
Preface
This article mainly introduces the relevant solutions about linux/mac installing mysql to forget the password, and shares it for your reference. The following words are not much to say, let's take a look at the detailed introduction.
Use equipment
Computer: linux or like-linux os
mysql version: 5.7 +
Problem description
After the installation is complete, you cannot pass the command
mysql -u root
Connecting to the database
Solution
The server of mysql installed through dmg, and the installation location is in
/usr/local/mysql-version-name-.../
By entering the directory and then entering the
cd ./bin
# If you are running mysql , Close mysql Services
$ sudo lsof -i:3306
$ sudo kill -9 mysql-pid
# Open mysql Safe mode
$ sudo ./mysqld_safe --skip-grant-tables
# Enter mysql shell
$ sudo ./mysql -u root
# Modify mysql.user In the table root User password
$ update mysql.user set authentication_string=PASSWORD('you password') where User='root';
# The modification here is complete.
Subsequent language
After modification, if you use navicat connection to change the database, you will be prompted to change the password and re-enter the password. so re-modifies OK because the password entered through Safe Mode is still marked as expired.
Summarize