用户工具

站点工具


zh:notes:centos_mysql_pwd

这是本文档旧的修订版!


Reset the Password of MySQL in the CentOS

Stop mysql Service

> systemctl stop mysqld

Set the Environment Option

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

Login as root without Password

> mysql -uroot

Update the Password

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

Stop mysql

> systemctl stop mysqld

Unset the MySQL Environment Option

> systemctl unset-environment MYSQLD_OPTS

Start mysql

> systemctl start mysqld

Login with New Password

> mysql -uroot -p
zh/notes/centos_mysql_pwd.1666442784.txt.gz · 最后更改: 2022/10/22 20:46 由 pzczxs