Linux

Forgot the password of mysql root, can not find the processing method of my.cnf in etc.

2021年5月4日

View the mysql installation and running path

ps -ef | grep mysql

/usr/local/mysql/libexec/lib: operating path

–basedir=/usr/local/mysql/: installation path

-datadir=/usr/local/mysql/: The storage path of the database file

cd /usr/local/mysql/
vi my.cnf

Insert in my.cnf

skip-grant-tables

Save after editing

Restart mysql service

service mysqld restart

Change root password

After restarting, execute mysql -uroot -p (Enter directly without a password) to enter the mysql command line

Change Password

update mysql.user set password=PASSWORD('your-new-passwd') where User='root';
  • Re-execute vi /etc/my.cnf, then delete the skip-grant-tables just added, and restart mysql

You Might Also Like

No Comments

Leave a Reply

%d 博主赞过: