CRON 作业的 MySQL 权限
我编写了一个 PHP 脚本,每天由 CRON 执行,以清理文件并删除旧的数据库条目。
该脚本运行没有问题,所以我知道这不是 CRON 问题。
问题是我收到以下错误:
警告:PDOStatement::execute() [pdostatement.execute]:SQLSTATE[42000]:语法错误或访问冲突:1142 SELECT 命令被拒绝给用户“username”@“localhost”表/cron_removeOld.php 中第 35 行的“users”
我为后端管理员用户使用相同的数据库凭据,所以我知道他们有 SELECT 权限。我想知道这是否与在网络服务器外部运行的脚本有关?
任何帮助将不胜感激!
Cron:
20 0 * * * php -q /home/user/public_html/tssol/contract/admin/cron_removeOld.php
PHP(第 35 行):
$stmt = $dbh->prepare("SELECT idusers, contract FROM users WHERE contractExpireDate <= NOW()");
数据库信用信息位于与其他页面共享的包含文件中,所以我知道这不是问题。如果您认为有帮助,将发布
I have written a PHP script to be executed by CRON on a daily basis to clean files and remove old database entries..
The script has no problems being run, so I know its not a CRON issue.
The problem is that I get the following error:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'username'@'localhost' for table 'users' in /cron_removeOld.php on line 35
I am using the same DB credentials for the backend admin users, so I know they have SELECT privileges. I'm wondering if it has something to do with the script being run outside of the webserver?
Any help would be greatly appreciated!
Cron:
20 0 * * * php -q /home/user/public_html/tssol/contract/admin/cron_removeOld.php
PHP (Line 35):
$stmt = $dbh->prepare("SELECT idusers, contract FROM users WHERE contractExpireDate <= NOW()");
The db creds are in an include file that is shared with other pages so I know thats not an issue..will post if you think it will help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MySQL 权限与 CLI 或其他方式执行的 PHP 无关。
检查您的 mysql 用户是否具有 users 表的 SELECT 权限
MySQL permission has nothing to do with PHP executed by CLI or whatever.
Check if your mysql user has the SELECT provileges for users table