简体   繁体   中英

`1044 (42000): Access denied for user 'user_admin'@'%' to database 'mysql'`

I created an cloud SQL table on Azure. I accessed it using MySQLWorkbench & DbVisualizer. I then wrote a query to create a table as follows:

"CREATE TABLE `mysql`.`actual_sales` (
                              `Timestamp` TIMESTAMP NOT NULL,
                              `Transaction` INT NOT NULL, 
                              `Item` VARCHAR(255) NOT NULL, 
                              `restaurant_ID` VARCHAR(255) NOT NULL);"

However, after I ran it, I got the following error: 1044 (42000): Access denied for user 'user_admin'@'%' to database 'mysql'

I checked the privileges using the following query:

SELECT * FROM `mysql`.`user` WHERE `User` = 'user_admin';

and I noticed that Super_priv , Create_tablespace_priv are set to N .

I tried to update them to Y with the following:

UPDATE `mysql`.`user` SET `Super_priv` = 'Y' WHERE `User` = 'user_admin';
UPDATE `mysql`.`user` SET `Create_tablespace_priv` = 'Y' WHERE `User` = 'user_admin';
FLUSH PRIVILEGES;
SELECT `User`, `Grant_priv` FROM `mysql`.`user`;

However, again I got 1044 (42000): Access denied for user 'user_admin'@'%' to database 'mysql'

What is going on here? How do I go about fixing this?

We can not create tables under the default database mysql . You need to crate a new database.

create database test1;

use test1;

CREATE TABLE `test1`.`actual_sales` (
                              `Timestamp` TIMESTAMP NOT NULL,
                              `Transaction` INT NOT NULL, 
                              `Item` VARCHAR(255) NOT NULL, 
                              `restaurant_ID` VARCHAR(255) NOT NULL);

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM