mysql访问被拒绝_MySQL无法连接-访问被拒绝(使用密码是)

bd96500e110b49cbb3cd949968f18be7.png

I have hosting provided by eleven 2 and I just created a new MySQL user and gave it access to every action listed.

I'm getting the following error

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

Here is my config file

//connection details have been removed for posting purposes

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

?>

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

FLUSH PRIVILEGES;

But I got the following error "#1044 - Access denied for user". When I log into the CPanel and check out the database users, it shows the user that I tried to log in as, so I'm confused as to why it won't work.

EDIT - I got it to work. There was something wrong with the server. Contacted the host and they took care of it. Thanks for the replies.

解决方案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

Temporarily, I'd suggest changing your databse password to that of your Cpanel account just to eliminate any doubts.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值