MariaDB 10.4.13 でのルートのパスワードを忘れた時に、再設定する方法です。
次のページを参考にしました。
[How To Reset Your MySQL or MariaDB Root Password](https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mari
adb-root-password)
- mariadb の停止
sudo systemctl stop mysqld
- セーフモードで mariadb を立ち上げる
sudo mysqld_safe --skip-grant-tables --skip-networking &
- root でアクセス
$ mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.13-MariaDB Arch Linux
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
- グラントテーブルのロード
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.003 sec)
- root パスワードの変更
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'tiger123';
- 結果を反映して、接続の遮断
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit;
Bye
- セーフモードで動いている mariadb の停止
$ ps ax | grep mysql
5284 pts/1 S 0:00 sudo mysqld_safe --skip-grant-tables --skip-networking
5285 pts/1 S 0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables --skip-networking
5370 pts/1 Sl 0:00 /usr/bin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --skip-grant-tables --skip-networking --log-error=/var/lib/mysql/iwata.err --pid-file=iwata.pid
5479 pts/1 S+ 0:00 grep mysql
$ sudo kill -9 5284 5285 5370
[1]+ Killed sudo mysqld_safe --skip-grant-tables --skip-networking
- mariadb を起動
sudo systemctl start mysqld
- root で接続
$ mysql -uroot -ptiger123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.4.13-MariaDB Arch Linux
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>