ブログ - Raspbian 9.4上にMySQL(marinadb)をインストールしてみた その2 rootユーザのパスワード設定
Raspbian 9.4上にMySQL(marinadb)をインストールしてみた その2 rootユーザのパスワード設定
- カテゴリ :
- PC » Raspberry Pi
- ブロガー :
- ujpblog 2018/9/2 17:35
MySQL(mariadb)が起動していることを確認.
MySQL Monitorを使い,管理者ユーザのrootでアクセスする.パスワードは設定されてない.
接続できました.
MySQL Monitorから一旦切断して,mysqladminコマンドを使ってパスワードを設定する.
この場合,rootユーザのパスワードはnew-passwordに変更された.パスワードリクエストを入れて接続してみる.
パスワード入れて接続できました.
mysqlデータベースにあるユーザテーブルを確認してみる.
現在はOSユーザをrootで接続しているので,RaspbianのOSユーザpiユーザで接続してみる.
アクセスできない.困りますな..
root@raspberrypi:/home/pi# service mysql status🆑
● mariadb.service - MariaDB 10.1.35 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running)🈁 since Sun 2018-09-02 02:29:36 JST; 12h ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 3607 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, s
Process: 3605 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Process: 3479 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galer
Process: 3475 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, st
Process: 3472 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, sta
Main PID: 3578 (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─3578 /usr/sbin/mysqld
9月 02 02:29:33 raspberrypi systemd[1]: Starting MariaDB 10.1.35 database server...
9月 02 02:29:35 raspberrypi mysqld[3578]: 2018-09-02 2:29:35 1996419088 [Note] /usr/sbin/mysqld (mysqld 1
9月 02 02:29:36 raspberrypi systemd[1]: Started MariaDB 10.1.35 database server.
root@raspberrypi:/home/pi#
root@raspberrypi:/home/pi# mysql -uroot🆑
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.35-MariaDB-1 Raspbian testing-staging
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)]>
MySQL Monitorから一旦切断して,mysqladminコマンドを使ってパスワードを設定する.
MariaDB [(none)]> quit🆑
Bye🈁
root@raspberrypi:/home/pi#
root@raspberrypi:/home/pi# mysqladmin -u root password 'new-password'🆑
root@raspberrypi:/home/pi#
root@raspberrypi:/home/pi# mysql -uroot -p🆑
Enter password:🈁
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.1.35-MariaDB-1 Raspbian testing-staging
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)]>
root@raspberrypi:/home/pi#
mysqlデータベースにあるユーザテーブルを確認してみる.
MariaDB [(none)]> use mysq🆑
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed🈁
MariaDB [mysql]> select user,host,password from user;🆑
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *B6099A7816C886616E7B526566BA33464BF9AC3B |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec)
MariaDB [mysql]>
MariaDB [mysql]> quit🆑
Bye
root@raspberrypi:/home/pi# exit🆑
exit
pi@raspberrypi:~ $ whoami🆑
pi🈁
pi@raspberrypi:~ $ mysql -uroot -p🆑
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'🈁
pi@raspberrypi:~ $