用户访问数据库被拒绝 [英] Access denied for user to database

查看:787
本文介绍了用户访问数据库被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个SQL查询并使用PHP程序/脚本将其发送到MySQL服务器。一切都工作正常,连接很好,直到我尝试创建数据库。然后我收到了这个错误:


错误:访问被拒绝用户'''''''localhost''数据库''petcatalog''


有谁知道为什么我没有连接以及我如何解决这个问题?


谢谢


PS

我知道我可以使用命令提示符来构建数据库,但我想完成这个使用php脚本建立数据库的项目来连接mysql服务器。

I have built an SQL query and sent it to the MySQL Server using a PHP program/script. Everything was working fine and the connection was good until I attempted to CREATE DATABASE. Then I got this error:

Error: Access denied for user ''''@''localhost'' to database ''petcatalog''

Does anyone know why I am not connecting and how I fix this?

Thanks

P.S.
I know I can use the command prompt to build a database but I would like to complete this project of building a database using php scripts to connect with mysql server.

推荐答案

什么是完整的错误消息?它将包括类似''使用密码是''。
What is the full error message? It''ll include something like ''USING PASSWORD yes''.


它看起来也没有传递登录名。
it also looks like there’s no login name passed.


注意你需要在创建数据库之前拥有CREATE权限。这意味着,在创建数据库之前,具有GRANT权限的用户(如root)需要发出 GRANT 命令,为您在脚本中使用的用户创建数据库。


因此,你通常只是使用admin用户创建数据库更好。无论如何,您将不得不使用它来授予权限。
Note that you need to have the CREATE privilege for the database before you create it. Meaning that, before you create the database, a user with the GRANT privilege (like root) needs to issue a GRANT command, giving the user you are using in your scripts permission to create the database.

Because of this, you are generally just better of creating the database using the admin user. You are going to have to use it to grant the privileges anyways.


这篇关于用户访问数据库被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆