【MySQL】关于MySQL的root用户授权
一、实验环境
# systemctl status mysqld
# cat /etc/systemd/system/mysqld.service
# cat /opt/mysqlconfig/mysqld.cnf
二、问题背景
mysql> CREATE DATABASE IF NOT EXISTS test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> grant all privileges on test.* to 'test_user'@'%' IDENTIFIED BY '[email protected]';
报错:1044 - Access denied for user 'root'@'%' to database 'test'
三、问题解决
# docker ps | grep mysql
# docker exec -it mysql mysql -u root -p"[email protected]"
mysql> select user,host from mysql.user;
mysql> show grants for [email protected]'%';
mysql> show grants for [email protected]'localhost';