php phpMyAdmin 错误: mysqli_real_connect(): (HY000/1045): 用户 'pma'@'localhost' 访问被拒绝(使用密码:NO)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46736319/
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
phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)
提问by E. AMARAL
I keep getting the following errors with mysql connection through XAMPP and I don't know what to do:
我通过 XAMPP 使用 mysql 连接时不断收到以下错误,我不知道该怎么办:
That's the code in the config.inc.php
那是 config.inc.php 中的代码
<?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE
SECURE COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';
/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';
/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
/*
* End of servers configuration
*/
?>
I've already reset the password from MySql from the command line two times and added the changes to this code above and to the php.ini file, but at each time it goes back to the error. Any help?
我已经两次从命令行从 MySql 重置密码,并将更改添加到上面的代码和 php.ini 文件中,但每次都会返回错误。有什么帮助吗?
回答by Javier Leonardo Anca Gulla
yo need create the user "pma" in mysql or change this lines(user and password for mysql):
您需要在 mysql 中创建用户“pma”或更改此行(mysql 的用户和密码):
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';
Linux: /etc/phpmyadmin/config.inc.php
Linux: /etc/phpmyadmin/config.inc.php
回答by sam.stack
Add this line to the file xampp\phpMyAdmin\config.inc
:
将此行添加到文件中xampp\phpMyAdmin\config.inc
:
$cfg['Servers'][$i]['port'] = '3307';
Here, my port is 3307
, you can change it to yours.
在这里,我的端口是3307
,您可以将其更改为您的。
回答by Wasim Khan
In terminal, log into MySQL as root. You may have created a root password when you installed MySQL for the first time or the password could be blank, in which case you can just press ENTER when prompted for a password.
在终端中,以 root 身份登录 MySQL。您可能在第一次安装 MySQL 时创建了 root 密码,或者密码可能为空,在这种情况下,您可以在提示输入密码时按 ENTER 键。
sudo mysql -p -u root
Now add a new MySQL user with the username of your choice. In this example we are calling it pmauser (for phpmyadmin user). Make sure to replace password_here with your own. You can generate a password here. The % symbol here tells MySQL to allow this user to log in from anywhere remotely. If you wanted heightened security, you could replace this with an IP address.
现在使用您选择的用户名添加一个新的 MySQL 用户。在这个例子中,我们称它为 pmauser(对于 phpmyadmin 用户)。确保将 password_here 替换为您自己的。您可以在此处生成密码。这里的 % 符号告诉 MySQL 允许该用户从任何地方远程登录。如果您想要更高的安全性,您可以将其替换为 IP 地址。
CREATE USER 'pmauser'@'%' IDENTIFIED BY 'password_here';
Now we will grant superuser privilege to our new user.
现在我们将授予我们的新用户超级用户权限。
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;
Then go to config.inc.php ( in ubuntu, /etc/phpmyadmin/config.inc.php )
然后转到 config.inc.php (在 ubuntu 中, /etc/phpmyadmin/config.inc.php )
/* User for advanced features */
/* 高级功能的用户 */
$cfg['Servers'][$i]['controluser'] = 'pmauser';
$cfg['Servers'][$i]['controlpass'] = 'password_here';
回答by taufik
Add these lines to the file xampp\phpMyAdmin\config.inc
:
将这些行添加到文件中xampp\phpMyAdmin\config.inc
:
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = '';
回答by Saurabh Naikele
The Connection for controluser as defined in your configuration failed, right after:
配置中定义的 controluser 连接失败,紧接着:
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'you_password';
回答by User Rebo
Linux / Ubuntu:
If installed phpmyadmin via apt:
sudo apt-get install phpmyadmin php-mbstring
Linux / Ubuntu:如果通过 apt 安装了 phpmyadmin:
sudo apt-get install phpmyadmin php-mbstring
Can check /etc/phpmyadmin/config-db.php
for changing the user credentials.
可以检查/etc/phpmyadmin/config-db.php
更改用户凭据。
$dbuser='pma';
$dbpass='my_pass';
$basepath='';
$dbname='phpmyadmin';
$dbserver='localhost';
$dbport='3306';
$dbtype='mysql';
回答by A. Askarov
My default 3306 port was in use, so Ive changed it to 8111, then I had this error. Ive fixed it by adding
我的默认 3306 端口正在使用中,所以我将其更改为 8111,然后出现此错误。我已经通过添加修复它
$cfg['Servers'][$i]['port'] = '8111';
into config.inc.php . If you are using different port number then set yours.
进入 config.inc.php 。如果您使用不同的端口号,请设置您的端口号。
回答by nicozica
I experienced the same errors on a fresh install of VestaCP. I solved the issues by following the instructions on this video.
我在全新安装 VestaCP 时遇到了同样的错误。我按照此视频中的说明解决了这些问题。
- Go to phpmyadmin-fixerand run the appropriate command.
- Restart Apache, NGINX and MySQL servers.
- That's it!
- 转到phpmyadmin-fixer并运行适当的命令。
- 重启 Apache、NGINX 和 MySQL 服务器。
- 就是这样!
回答by Daniel
I just finished setting up my XAMPP on the MAC and had the same trouble. I just fixed it. It is not quite clear what OS you're using but you need to run the XAMPP security. You indicate you've done that, but here it is anyway for the MAC
我刚刚在 MAC 上设置了我的 XAMPP 并遇到了同样的问题。我刚修好。不太清楚您使用的是什么操作系统,但您需要运行 XAMPP 安全性。你表明你已经这样做了,但无论如何它都是针对 MAC 的
sudo /Applications/XAMPP/xamppfiles/xampp security
Set your password on the questions you get.
为您收到的问题设置密码。
In you're phpmyadmin import the "create_tables.sql" .. Which can be found in the ./phpmyadmin/sql folder.
在你的 phpmyadmin 中导入“create_tables.sql”.. 可以在 ./phpmyadmin/sql 文件夹中找到。
Next open the config.inc.php
file inside the ./phpmyadmin
folder.
接下来打开config.inc.php
文件./phpmyadmin
夹内的文件。
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'you_password';
Make sure to log out and log in to reflect the changes within phpmyadmin
确保注销并登录以反映 phpmyadmin 中的更改
回答by TheSatinKnight
consider changing host entry 127.0.0.1
to localhost
or even the IP address of the server.
考虑更改主机条目127.0.0.1
到localhost
甚至服务器的IP地址。
$cfg['Servers'][$i]['host']