[root]# mysql -u root
# データベース mysql へ移動 DB > use mysql # user テーブル確認 DB > select host,user,password from user;
Host | User | Password |
---|---|---|
localhost | mariadb.sys | |
localhost | root | invalid |
localhost | mysql | invalid |
localhost | ||
www.example.com |
# mariadb.sys のパスワード設定 DB > set password for 'mariadb.sys'@localhost = password( 'パスワード' ); # root のパスワード設定 DB > set password for root@localhost = password( 'パスワード' ); # mysql のパスワード設定 DB > set password for mysql@localhost = password( 'パスワード' ); # 匿名ユーザーの削除 DB > delete from user where user = ''; # 新規ユーザー作成 DB > grant all on *.* to ユーザー名@localhost identified by 'パスワード'; # 新規ユーザー作成(権限を select, insert, update, delete に限定) DB > grant select,insert,update,delete on *.* to ユーザー名@localhost identified by 'パスワード'; # host が localhost 以外削除 DB > delete from user where host != 'localhost'; # user テーブル確認 DB > select host,user,password from user;
Host | User | Password |
---|---|---|
localhost | mariadb.sys | *A0C0E... |
localhost | root | *D7989... |
localhost | mysql | *4B9C5... |
localhost | username | *65E0B... |
# 更新 DB > flush privileges; DB > exit
[root]# killall mariadbd # 停止