PHP/PDO - 刷新权限
我正在使用一个脚本进行一些 mysql 服务器管理,当向 MySQL 用户添加新权限时,该脚本会刷新 MySQL 用户权限。
我正在使用 PDO 类来执行查询,但是当我执行简单操作时
FLUSH PRIVILEGES;
,我得到了 for
$connection->exec('FLUSH PRIVILEGES;');
和
$connection->query('FLUSH PRIVILEGES;');
SQLSTATE[42S02]:基表或视图 未找到:1146 表 'mysql.servers' 不存在
是否可以使用 PDO 类执行此类查询,或者我是否必须求助于使用 mysql(i)?
I'm doing some mysql server management with a script that flushes the MySQL users privileges when new privileges are added to a MySQL user.
I'm using the PDO class to do my queries, but when I do a simple
FLUSH PRIVILEGES;
I get, for
$connection->exec('FLUSH PRIVILEGES;');
and
$connection->query('FLUSH PRIVILEGES;');
SQLSTATE[42S02]: Base table or view
not found: 1146 Table 'mysql.servers'
doesn't exist
Is it possible to do such query with the PDO class or do I have to resort to using mysql(i)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚尝试了以下部分代码:
并且我没有收到任何类型的错误,如您所描述的错误。
你确定你的 MySQL 服务器没有问题吗?
你的错误消息说表“
mysql.servers
”不存在...但是当我查看本地 MySQL 服务器时,有这样一个表 - 你确定你的安装/配置是没有“损坏”并且您没有删除该表或类似的内容?顺便说一句,这似乎不是您没有的某种特权:如果您在没有所需特权的情况下尝试
刷新特权
,您会收到以下错误:“SQLSTATE[42000]:语法错误或访问冲突:1227 访问被拒绝;此操作需要 RELOAD 权限
”I've just tried the following portion of code :
And I don't get any kind of error like the one you are describing.
Are you sure you don't have some problem with you MySQL server ?
Your error message says that table "
mysql.servers
" doesn't exists... But when I look at my local MySQL server, there is such a table -- are you sure your installation/configuration is not "broken" and you didn't delete that table or anything like that ?BTW, it doesn't seem to be some kind of privilege you're not having : if you try to
flush privileges
without having the required privilege, you get the following error : "SQLSTATE[42000]: Syntax error or access violation: 1227 Access denied; you need the RELOAD privilege for this operation
"