加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Mysql无法连接 – 访问被拒绝(使用密码是)

发布时间:2020-12-13 16:29:49 所属栏目:PHP教程 来源:网络整理
导读:我有11个2提供的托管,我刚刚创建了一个新的 MySQL用户,并允许它访问列出的每个操作. 我收到以下错误 Warning: mysql_connect() [function.mysql-connect]: Access denied for user '(username is here,removed for posting)' (using password: YES) in /home
我有11个2提供的托管,我刚刚创建了一个新的 MySQL用户,并允许它访问列出的每个操作.

我收到以下错误

Warning: mysql_connect() [function.mysql-connect]: Access denied for user '(username is here,removed for posting)' (using password: YES) in /home/.../public_html/config.php on line 10

这是我的配置文件

//connection details have been removed for posting purposes

<?php

 define('SQL_SERVER',''); // Database Server
 define('SQL_USER',''); //  User
 define('SQL_PASS',''); //  Password
 define('SQL_DB',''); //  database



 mysql_connect(SQL_SERVER,SQL_USER,SQL_PASS) or die("Error: ".mysql_error()); // Connection to the server
 mysql_select_db(SQL_DB) or die("Error: ".mysql_error()); // Connecting to the database
?>

我尝试按照这篇文章Access denied for user ‘someuser’@’localhost’ (using password: YES)的建议执行以下操作

GRANT ALL PRIVILEGES ON databasename.* TO 'bookorama'@'%' IDENTIFIED BY 'yourpassword';
FLUSH PRIVILEGES;

但我收到以下错误“#1044 – 用户拒绝访问”.当我登录到CPanel并检出数据库用户时,它会显示我尝试登录的用户,因此我很困惑为什么它不起作用.

编辑 – 我得到了它的工作.服务器出了问题.与主人联系,他们负责处理.谢谢你的回复.

我偶然发现了有关Cpanel http://www.inmotionhosting.com/support/community-support/databases/1045-access-denied-for-user-mysql-error的连接信息

Your cPanel username and password can be used to connect to your databases (as well as your cPanel). If you’re connecting to your database using your cPanel username and password,you can reset your cPanel password to ensure you are using the correct username and password.

If you setup a MySQL username and password specifically for accessing a database,you’ll want to ensure you are using the correct username in your php scripts. For example,MySQL usernames are always in this format:

cpanel-username_mysql-username

If your cPanel username is userna5 and you created a database username of dbuser1,then the actual database username would be:

userna5_dbuser1

暂时,我建议将您的数据库密码更改为您的Cpanel帐户密码,以消除任何疑虑.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读