用户“root”@localhost 的访问被拒绝 mysql 错误 1045
我是 PHP 新手。执行我的应用程序时出现以下错误:
在 phpMyadmin 中,代码是这样的
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;
当我备份时,我已将上面的代码更改为
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'Pass123';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;
现在我收到以下错误
用户“root”@“localhost”的访问被拒绝(使用密码:YES)MySQL 错误#:1045
请告诉我,这里出了什么问题。
I am new to PHP. I get the following error when executing my application:
In phpMyadmin the code is like this
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;
As I have taken back up, I have change the above code to
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'Pass123';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;
Now I am get the following error
Access denied for user 'root'@'localhost' (using password: YES) MySQL Error # :1045
Please let me know, what went wrong here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
在这个问题上浪费了大部分时间后,事实证明我所要做的就是提供非本地主机主机名。我不知道为什么(允许用户从任何主机连接),但它有效!
在 PHP 中:
After wasting most of a day on this problem, it turned out that all i had to do was supply the non-localhost hostname. I've no idea why (the user is allowed to connect from Any host), but it works!
And in PHP:
这里没有人提到(由于某种原因),分配给您的用户的主机可能是错误的。当它显示
root@localhost
时,表示用户root
的主机为localhost
。在某些服务器上,默认的
root
可能不在localhost
上。尝试以下操作:[电子邮件受保护]
root@[你的主机名]
Nobody here has mentioned that (for some reason or another), the host assigned to your user might be wrong. When it says
root@localhost
it means the userroot
with the host oflocalhost
.On some servers, the default
root
might not be onlocalhost
. Try these:[email protected]
root@[yourhostname]
请检查您在此处输入的密码。
当您的密码与原始密码不匹配时,就会出现此类错误。
Please check the password which you typed here.
These kind of errors come when youre password is not matching with the original password.
确保您是否为 mysql 指定了密码
make sure whether you've assigned a password for mysql
用于重置您的密码
请查看此页面 http://dev.mysql.com/ doc/refman/5.0/en/resetting-permissions.html
For resetting youre password
please look into this page http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
确保密码正确(大写锁定?),也许使用原始 IP 地址,即 127.0.0.1
Make sure the password correct (caps lock?) and perhaps use the raw IP address i.e. 127.0.0.1
MySQL 服务器及其运行端口可能存在问题。默认值为 3306。如果不起作用,请更改 my.ini 中的端口(或 mysql-ini 文件名),并更改配置中的端口引用。 inc.php 在 phpmyadmin 文件夹中。
所以,这里解释的错误(Gnanendra)
可能会出现,因为 MySQL 服务器未正确运行。
另请查看此帖子以获取有关此问题的更多信息:
无法启动服务器:绑定在 TCP/IP 端口上:没有这样的文件或目录
There can be a problem with MySQL-server and the port on which it is run. Default is 3306. If it doesn't work, change the port in the
my.ini
(ór whatever the mysql-ini filename is) AND also change the port-reference in theconfig.inc.php
in the phpmyadmin-folder.So, the error that is explained here (by Gnanendra)
may be given because MySQL-server is not run correctly.
Also check this post for more information on this issue:
Can't start server: Bind on TCP/IP port: No such file or directory