How does one install mysql on linux/mac and forget the password?
Preface
This article describes how to install mysql on linux/mac and how to forget the password. I will share the information for your reference. I will not talk about it here. Let's take a look at the detailed introduction.
Devices Used
COMPUTER: linux or like-linux OS
Mysql version: 5.7 +
Problem description
After the installation is complete, you cannot run the commandmysql -u root Connect to the database
Solution
Generally, the mysql server installed through dmg is located/usr/local/mysql-version-name-.../
Enter this directory and then entercd ./bin
# If you are running mysql, disable mysql service $ sudo lsof-I: 3306 $ sudo kill-9 mysql-pid # enable mysql security mode $ sudo. /mysqld_safe -- skip-grant-tables # Enter mysql shell $ sudo. /mysql-u root # modify mysql. the root user password in the user table $ update mysql. user set authentication_string = PASSWORD ('You password') where User = 'root'; # The modification is complete.
Background
After the modification, if you use a navicat connection to change the database, you will be prompted to change the password and re-enter the password. Because the modified password is still marked as expired in security mode, so can be changed again.
Summary
The above is all the content of this article. There are still many shortcomings in this article. I hope this article will have some reference and learning value for everyone's learning or work. If you have any questions, please leave a message, thank you for your support.