4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MariaDB で、root のパスワードを再設定

Posted at

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)

  1. mariadb の停止
sudo systemctl stop mysqld
  1. セーフモードで mariadb を立ち上げる
sudo mysqld_safe --skip-grant-tables --skip-networking &
  1. 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)]>
  1. グラントテーブルのロード
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.003 sec)
  1. root パスワードの変更
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'tiger123';
  1. 結果を反映して、接続の遮断
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> exit;
Bye
  1. セーフモードで動いている 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
  1. mariadb を起動
sudo systemctl start mysqld
  1. 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)]> 
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?