mysql added new users unable to log in the solution

  • 2020-05-14 05:04:38
  • OfStack

Today, I installed openstack folsom version. After installing mysql, I added corresponding database and users for each service
Unable to log in mysql with the new user. My methods to increase users are as follows:
mysql -uroot -p$MYSQL_PASS < < EOF
CREATE DATABASE nova;
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%'IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%'IDENTIFIED BY '$MYSQL_PASS';
CREATE DATABASE quantum;
GRANT ALL PRIVILEGES ON quantum.* TO 'quantum'@'%'IDENTIFIED BY '$MYSQL_PASS';
FLUSH PRIVILEGES;
EOF
But user login failed:
root@controller:~# mysql -h localhost -ukeystone -ppassword
ERROR 1045 (28000): Access denied for user 'keystone'@'localhost' (using password: YES)
Solutions:
After adding regular users, execute:
mysql > use mysql
mysql > delete from user where user='';
mysql > flush privileges;
Delete anonymous users.
OK, done, enjoy!

Related articles: