MySQL root ユーザのパスワード再設定
2018-03-18 (Sun) · 85 words

前提

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

MySQLの設定変更

/etc/my.cnfskip-grant-tablesを追加(パスワードなしでログインする)

# vi /etc/my.cnf
// ADD EOF "skip-grant-tables"

MySQLを使っているサービスを停止させる

MySQLを再起動

# systemctl restart mysqld

rootユーザのパスワード変更

# mysql -u root
mysql> use mysql
・・・
Database changed
mysql> UPDATE user SET authentication_string=password('新規パスワード') WHERE user='root';
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql> quit

MySQLを再起動

/etc/my.cnfからskip-grant-tablesを削除(パスワードなしでログインする)

# vi /etc/my.cnf
// DELETE EOF "skip-grant-tables"

MySQLを使っているサービスを停止させる

MySQLを再起動

# systemctl restart mysqld

Top     back     Posts     Tags     About Me