I have MySQL user company_dev
who has access to DB company_dev
, and user company_prod
who has access to DB company_prod
.
When I'm logged as a root on my Debian server, I try to import SQL file to my company_dev
DB.
This is the command I'm using: mysql -u company_dev -pMyPassword company_dev < some_db.sql
But I get this error:
Access denied for user 'company_dev'@'localhost' to database 'company_prod'
If I correctly understand this message - there was an attempt to write a file some_db.sql
to the company_prod
DB, even though I put company_dev
in the command?!
How is it possible?
Note: logged in as root on the server is not analogous to the root user of the mysql server, they are different.
Please check the following:
Check the password is right, also might need to put it in quotes: -p'passWordHere'
The file some_db.sql probably has some statement to insert into someDbName. Check it.
the user you are importing with is -u company_dev you need to make sure this user has permissions.
To grant permissions, use this sql, you will need something like this:
GRANT [type of permission] ON company_prod TO ‘company_dev’@'localhost’;
This all depends on the permissions you need to give the user, all privileges would be something like this:
GRANT ALL PRIVILEGES ON * . * TO 'company_dev'@'localhost';
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.