My days of...

生活のことなど、がんばろう

MariaDBにログインできなかった際に行なった対処方法

VagrantUbuntu 18.04でphpmyadminでログインできなかった為、メモ

MariaDB [(none)]> use mysql
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]> update user set password=PASSWORD("root") where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

MariaDB [mysql]> update user set plugin="mysql_native_password";
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

MariaDB [mysql]> quit;

とすることで、とりあえずローカルのphpmyadminへはログインユーザー、パスワード共にrootにして入れるようになりました。あくまで自分の場合。

原因としては、unix_socketがプラグインとして登録されている為、適当な意訳として思い込んでいるのは、Ubuntuでユーザを作らなければログインできませんということ。だからコマンドで

mysql -u root -p

とやってもエラーが表示されて

sudo mysql -u root -p またはsudo mysql -u 

としなければ(管理者/登録ユーザーにならなければ)、mysql(今回は、MariaDB)に入れなかったみたい。セキュリティを高くして、今までのやり方などがどんどん変わりますね。検索してもよくわからんことが多いです。

 

参考にさせていただいたサイト

Ubuntu 18.04 + MariaDB | 技術メモの壁

Ubunt 16.04でMariaDBをインストールするとパスワードが変 | 純規の暇人趣味ブログ

 

MariaDB&MySQL全機能バイブル

MariaDB&MySQL全機能バイブル

 
PHP7+MariaDB/MySQLマスターブック

PHP7+MariaDB/MySQLマスターブック