用户工具

站点工具


zh:notes:centos_mysql_pwd

Reset the Password of MySQL in the CentOS

Stop mysql Service

> systemctl stop mysqld.service

Set the Environment Option

> systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

Login as root without Password

> systemctl start mysqld.service
> mysql -uroot

Update the Password

mysql> USE mysql
mysql> ALTER USER "root"@"localhost" IDENTIFIED BY "MyNewPassword";
mysql> FLUSH PRIVILEGES;
mysql> quit

Stop mysql Service and Unset the Environment Option

> systemctl stop mysqld.service
> systemctl unset-environment MYSQLD_OPTS

Start mysql Service

> systemctl start mysqld.service

Login with New Password

> mysql -uroot -p
zh/notes/centos_mysql_pwd.txt · 最后更改: 2023/03/23 07:42 由 pzczxs