php Mysqli_real_connect(): (HY000/1045): 用户 'root'@'localhost' 访问被拒绝(使用密码:NO)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51125414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO)
提问by Keyz23
I'm using xampp. I also downloaded MySQL Database. Then I have created a database with Mysql Database, with
我正在使用 xampp。我还下载了 MySQL 数据库。然后我用 Mysql 数据库创建了一个数据库,用
- username: root,password = 123456789.
- 用户名:root,密码 = 123456789。
Then I start Xampp Apache and Mysql. When I try to connect to localhost:8080/phpmyadmin, I receive this kind of error:
然后我启动 Xampp Apache 和 Mysql。当我尝试连接到 localhost:8080/phpmyadmin 时,我收到此类错误:
Messaggio di MySQL: Documentazione
Impossibile connettersi: impostazioni non valide. mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO)
phpMyAdmin ha provato a connettersi al server MySQL, e il server ha rifiutato la connessione. Si dovrebbe controllare il nome dell'host, l'username e la password nel file di configurazione ed assicurarsi che corrispondano alle informazioni fornite dall'amministratore del server MySQL.
Messaggio di MySQL:Documentazione
Impossibile connettersi: impostazioni non valide。mysqli_real_connect(): (HY000/1045): 用户 'root'@'localhost' 访问被拒绝(使用密码:NO)
phpMyAdmin 是一个连接服务器 MySQL,e il 服务器 ha rifiutato la connessione。Si dovrebbe controllare il nome dell'host, l'username e la password nel file di configurazione ed assicurarsi che corrispondano alle informazioni fornite dall'amministratore del server MySQL。
So I think that I should modify the file:config.inc.php
but the problems are:
所以我认为我应该修改文件:config.inc.php
但问题是:
- I can't modify this file on Mac because it says that I'm not the superuser ( But I am).
- I don't know what I should modify.
- 我无法在 Mac 上修改此文件,因为它说我不是超级用户(但我是)。
- 我不知道我应该修改什么。
Can you help me to solve this problem? I need to create a simple login form in Java and I need the connection with a database (maybe you know some other solutions to do this.) Thank you.
你能帮我解决这个问题吗?我需要用 Java 创建一个简单的登录表单,我需要与数据库的连接(也许您知道其他一些解决方案来做到这一点。)谢谢。
回答by dcmp
I had the same problem.
我有同样的问题。
Probably you started XAMPP and clicked "Go to Application" and saw the "HOW-TO Guides" on the started website suggesting to change the root password.
可能您启动 XAMPP 并单击“转到应用程序”并在启动的网站上看到“操作指南”建议更改 root 密码。
Your error message says that you are trying to access the database without a password - however, you have already set a password for this database.
您的错误消息表明您试图在没有密码的情况下访问数据库 - 但是,您已经为此数据库设置了密码。
So, you could just delete your current root password (i.e. set an empty "" as the password) and later on change it - I guess you would like to just be able to access phpMyAdmin and this is the quickest solution.
因此,您可以删除当前的 root 密码(即设置一个空的“”作为密码),然后再更改它——我猜您只想能够访问 phpMyAdmin,这是最快的解决方案。
Start XAMPP and mount the data volume. Open Terminal and enter the following command:
启动 XAMPP 并挂载数据卷。打开终端并输入以下命令:
/opt/lampp/bin/mysqladmin --user=root --password=123456789 password ""
(here 123456789 is your current root password which gets replaced by an empty password)
(这里 123456789 是您当前的 root 密码,它将被空密码替换)
Now you should be able to access phpMyAdmin without any problems. But do not forget to set a password later on.
现在您应该可以毫无问题地访问 phpMyAdmin。但不要忘记稍后设置密码。
回答by Alexandre Almeida
Please, execute the following privileges command on your MySQL Server:
请在您的 MySQL 服务器上执行以下权限命令:
GRANT ALL ON *.* TO `root`@`localhost` IDENTIFIED BY '123456789';
GRANT ALL ON *.* TO `root`@`127.0.0.1` IDENTIFIED BY '123456789';
Did it solve your problem?
它解决了你的问题吗?
Cheers,
干杯,
回答by Diego Baulde
Use: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
使用:ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
This work for me. Regards
这对我有用。问候
回答by Martin Alvarado
I was facing a similar problem, the solution that worked for me was to go through the MariaDB that underlies XAMPP.
我遇到了类似的问题,对我有用的解决方案是通过作为 XAMPP 基础的 MariaDB。
1)Click on Open Terminal in the XAMPP utility.
1) 在 XAMPP 实用程序中单击 Open Terminal。
2) In Terminal enter:
2)在终端输入:
mysql -p
mysql -p
3) this will prompt you for a password - enter the one you had set in phpMyAdmin
3) 这将提示您输入密码 - 输入您在 phpMyAdmin 中设置的密码
4) SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');
4) SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');
This should void the root password and allow you to regain access.
这应该会使 root 密码无效并允许您重新获得访问权限。
回答by utku glsvn
Remove the MySQL file. I solved it in this way.
删除 MySQL 文件。我是这样解决的。