MySQL 1044 - 用户 'user'@'localhost' 对数据库 'db' 的访问被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21447790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:55:38  来源:igfitidea点击:

1044 - Access denied for user 'user'@'localhost' to database 'db'

mysqldatabasephpmyadmin

提问by user3141777

I tried a lot to import the sql script to create database and tables through phpmyadmin in the new site I hosted. But i'm getting the error,

我尝试了很多导入 sql 脚本以通过 phpmyadmin 在我托管的新站点中创建数据库和表。但我收到错误,

1044 - Access denied for user 'user'@'localhost' to database 'db'

1044 - 用户 'user'@'localhost' 对数据库 'db' 的访问被拒绝

I tried to create a sample db directly : create database sampled; I'm getting the same access denied error.

我试图直接创建一个示例数据库:create database sampled; 我收到相同的访问被拒绝错误。

I'm not able to grant privileges to the user also, i'm getting the same access denied error.

我也无法向用户授予权限,我收到了相同的访问被拒绝错误。

Following is the output of show grants command,

以下是 show grants 命令的输出,

show grants;
GRANT USAGE ON . TO 'someuser'@'localhost' IDENTIFIED BY PASSWORD 'somepw' 

GRANT ALL PRIVILEGES ON someuser\_%.* TO 'someuser'@'localhost' 

Any help would be appreciated. thank you.

任何帮助,将不胜感激。谢谢你。

回答by 5511002233

If you are using Godaddy then don'tdirectly go to phpMyAdmin and run the sql command.

如果您使用的是 Godaddy,则不要直接转到 phpMyAdmin 并运行 sql 命令。

You have to go to MySQL? Databasessection and create a database there. Then create a userand give it the permissionto access the database you just created. Now you can go to phpMyAdminand write your SQL commands.

你必须去MySQL吗?Databases部分并在那里创建一个数据库。然后创建一个用户并授予它访问您刚刚创建的数据库的权限。现在您可以转到phpMyAdmin并编写您的 SQL 命令。

Hope this helps

希望这可以帮助

回答by Abdul Manaf

It is clear that the user someuserdo not have proper privilege over the database db. You need to grant privileges for the user over the database to correct this issue.

很明显,用户someuser对数据库没有适当的权限db。您需要授予用户对数据库的权限才能更正此问题。

If you do bot have administrative rights contact your admin for granting privileges to someuseron that db

如果你做的机器人具有管理权限与您的管理员授予权限,以someuserdb

回答by Aziz

you have not exported database from localhost or from web server correctly follow these steps go to localhost database click export tab than select 'Custom - display all possible options 'check box few options will open in section 'output' change compression none to zipped and now click go button at bottom it will properly export your database you can now import to hosting or anywhere you want with no errors

您尚未从本地主机或 Web 服务器正确导出数据库,请按照以下步骤转到本地主机数据库单击导出选项卡,然后选择“自定义 - 显示所有可能的选项”复选框在“输出”部分将打开几个选项将压缩无更改为压缩,现在单击底部的 go 按钮,它将正确导出您的数据库,您现在可以导入到托管或任何您想要的地方,而不会出现错误

回答by Kuldeep Makwana

Must Ensure that your User_Name, Password and Database name are correct. If you are Deal with database 'sampled' then type 'sampled' in query instead of 'db' also must ensure that you don't have to use quota(') in Statement. For More and Accurate Detail visit Following link: http://onephin.com/1044-access-denied-user-user_namelocalhost-database-database_name/

必须确保您的用户名、密码和数据库名称正确。如果您处理数据库 'sampled',则在查询中键入 'sampled' 而不是 'db' 还必须确保您不必在 Statement 中使用 quota(')。如需更多准确的详细信息,请访问以下链接:http: //onephin.com/1044-access-denied-user-user_namelocalhost-database-database_name/

回答by BharathRao

For me the problem is I'm not having permissions to Create new Databasename or even Modify the name of the Database. You can contact your admin to avail privileges or if you want to quickly import the .sqlfile... then you can open the .sql file with text editor and find the following line:

对我来说,问题是我无权创建新的 Databasename 甚至修改数据库的名称。您可以联系您的管理员以获取权限,或者如果您想快速导入.sql文件...然后您可以使用文本编辑器打开 .sql 文件并找到以下行:

CREATE DATABASE IF NOT EXISTS `enter the existing db name` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `enter the existing db name`;

After that try to import the .sqlfile...now you can successfully import all the tables!

之后尝试导入.sql文件...现在您可以成功导入所有表!

回答by Mahmoud Abbas

I had the same problem i solve it buy change the GRANTEE and made the user he can do all the operation in PhpMyAdmin ,follow the steps :

我遇到了同样的问题,我解决了它购买更改 GRANTEE 并使用户可以在 PhpMyAdmin 中执行所有操作,请按照以下步骤操作:

  1. Enter to mysql in root permission but :

    sudo mysql Enter the password, and type this :

    SELECT * FROM information_schema.user_privileges; And see the user in IS_GRANTABLE is he yes or no. If he yes then see the PRIVILEGE_TYPE what it might it be just tow operation if it's true add the last operations. and see this linkto change IS_GRANTABLE from no to yes. I wish this could help you.

  1. 以 root 权限进入 mysql 但:

    sudo mysql 输入密码,然后输入:

    SELECT * FROM information_schema.user_privileges; 并查看 IS_GRANTABLE 中的用户是或否。如果他是,那么请查看 PRIVILEGE_TYPE 如果它是真的,那么它可能只是拖曳操作,添加最后的操作。并查看此链接以将 IS_GRANTABLE 从 no 更改为 yes。我希望这可以帮助你。