一、实验环境
# 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 'Test@123';
报错:1044 - Access denied for user 'root'@'%' to database 'test'
三、问题解决
# docker ps | grep mysql
# docker exec -it mysql mysql -u root -p"MySQL@123"
mysql> select user,host from mysql.user;
mysql> show grants for root@'%';
mysql> show grants for root@'localhost';