phpMyAdmin 无法连接到 MySQL 服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23883163/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:34:23  来源:igfitidea点击:

phpMyAdmin cannot connect to MySQL server

mysqlphpmyadmin

提问by Jasmine Ziz

I really need help to fix this error, because next Monday is my final year project presentation, please. I don't know how to fix this.

我真的需要帮助来修复这个错误,因为下周一是我最后一年的项目演示,拜托了。我不知道如何解决这个问题。

I've try to follow this http://www.ishaanrawat.com/solved-wampserver-1045-access-denied-for-user-rootlocalhost-using-password-no/instruction, but I get the same error.

我尝试按照此http://www.ishaanrawat.com/solved-wampserver-1045-access-denied-for-user-rootlocalhost-using-password-no/指令进行操作,但出现相同的错误。

And, a few minute ago, I uninstall wamp sever, in hope after installing it again, I can use my wamp server normally, but still the same error.

而且,几分钟前,我卸载了wamp sever,希望再次安装后,我可以正常使用我的wamp服务器,但仍然出现同样的错误。

Below is the error:

下面是错误:

MySQL said: Documentation

MySQL 说: 文档

1045 - Access denied for user 'root'@'localhost' (using password: NO)

1045 - 用户 'root'@'localhost' 的访问被拒绝(使用密码:NO)

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

phpMyAdmin 尝试连接 MySQL 服务器,服务器拒绝连接。您应该检查配置中的主机、用户名和密码,并确保它们与 MySQL 服务器管理员提供的信息相对应。

回答by Tiep Phan

You can watch to solve your problem
http://www.youtube.com/watch?v=BgcW4h6ZAro&t=7m21s
p/s: this is Vietnamese video :)
in config.inc.phpyou edit folowing code:

您可以观看以解决您的问题
http://www.youtube.com/watch?v=BgcW4h6ZAro&t=7m21s
p/s:这是越南视频 :)
config.inc.php您编辑以下代码时:

* First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
//uncomment this
$cfg['Servers'][$i]['auth_type'] = 'cookie';
//comment this
//$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

then exit wampserver, reopen wampserver, open PHPMyadmin, you'll show login form :)

然后退出wampserver,重新打开wampserver,打开PHPMyadmin,你会显示登录表单:)

回答by Ankit Shubham

This worked for me. Prior to installing WAMP, I had MySQL installed in my computer. The password required to open the MySQL command line client was, let's say "pw". Now, after installing WAMP, it gave the same error as your when I tried to open phpMyAdmin. How to fix this:

这对我有用。在安装 WAMP 之前,我在我的计算机中安装了 MySQL。打开 MySQL 命令行客户端所需的密码是“pw”。现在,在安装 WAMP 后,当我尝试打开 phpMyAdmin 时,它给出了与您相同的错误。如何解决这个问题:

  1. Open C:\wamp\apps\phpmyadmin4.1.14\config.inc.php
  2. Locate these lines:

    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';
    /* Server parameters /
    $cfg['Servers'][$i]['host'] = '127.0.0.1';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['compress'] = false;
    /
    Select mysql if your server does not have mysqli */
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;

  3. Change " $cfg['Servers'][$i]['AllowNoPassword'] = true;" to " $cfg['Servers'][$i]['AllowNoPassword'] = false;".

  4. Change " $cfg['Servers'][$i]['password'] = ''" to " $cfg['Servers'][$i]['password'] = 'pw'". (Remember to put your password instead of 'pw' ).

  5. Restart all services in WAMP and try opening phpMyAdmin again. Hope it works now!

  1. 打开 C:\wamp\apps\phpmyadmin4.1.14\config.inc.php
  2. 找到这些行:

    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['服务器'][$i]['密码'] = '';
    /* 服务器参数/
    $cfg['Servers'][$i]['host'] = '127.0.0.1';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['compress'] = false;
    /
    如果您的服务器没有 mysqli,请选择 mysql */
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;

  3. 将“ $cfg['Servers'][$i]['AllowNoPassword'] = true;”改为“ $cfg['Servers'][$i]['AllowNoPassword'] = false;”。

  4. 将“ $cfg['Servers'][$i]['password'] = ''”改为“ $cfg['Servers'][$i]['password'] = 'pw'”。(请记住输入您的密码而不是“ pw”)。

  5. 重新启动 WAMP 中的所有服务并再次尝试打开 phpMyAdmin。希望它现在有效!

回答by Abu Sufian

Go to phpMyAdmin folder inside of XAMPP or WAMPS server and open config.inc.php file. And Change username and password to set in your db.

转到 XAMPP 或 WAMPS 服务器内的 phpMyAdmin 文件夹并打开 config.inc.php 文件。并更改用户名和密码以在您的数据库中设置。

 /* 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'] = '';

回答by Sandeepa Rajoriya

u first change the "AllowNoPassword" value to false in config.inc.php. then set password for root then login to phpmyadmin.

u 首先在 config.inc.php 中将“AllowNoPassword”值更改为 false。然后为root设置密码,然后登录phpmyadmin。

回答by Vedant Jain

The solution is:

解决办法是:

  1. Backup All your projects and database first.

  2. Uninstall lamppfrom your system (Ubuntu 16.04).

  3. Re-install lampp.

  4. Open phpmyadmin. The error has not been removed yet.

  5. Open config.inc.phpof phpmyadminfolder.

  6. Make changes to these lines:

    /* Authentication type and info */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'your password';
    
  1. 首先备份所有项目和数据库。

  2. lampp从您的系统 (Ubuntu 16.04) 中卸载。

  3. 重新安装lampp

  4. 打开phpmyadmin。错误尚未消除。

  5. 打开config.inc.phpphpmyadmin文件夹中。

  6. 对这些行进行更改:

    /* Authentication type and info */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'your password';
    
  1. Now save the file (if unable to save then write):

    sudo -H gedit /opt/lampp/phpmyadmin/config.inc.php
    
  2. Restart your xamppserver.

  3. Go to localhost/phpmyadminagain. Try to login with rootas username and leave the passwords filed blank. If this doesn't works then login with the password you have entered.

  1. 现在保存文件(如果无法保存则写入):

    sudo -H gedit /opt/lampp/phpmyadmin/config.inc.php
    
  2. 重新启动您的xampp服务器。

  3. 再去localhost/phpmyadmin。尝试使用root用户名登录并将密码字段留空。如果这不起作用,请使用您输入的密码登录。

Good Luck!

祝你好运!

回答by alok

Remove xampp and install mysql,phpmyadmin,php5, apache2 manully.

删除 xampp 并手动安装 mysql、phpmyadmin、php5、apache2。

  1. sudo su
  2. apt-get install mysql-server mysql-client
  3. apt-get install apache2
  4. apt-get install php5 libapache2-mod-php5
  5. apt-cache search php5Pick the ones you need and install them like this: apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
  6. apt-get install phpmyadmin
  7. service apache2 restart
  8. then open http://127.0.0.1/phpmyadmin/
  1. sudo su
  2. apt-get install mysql-server mysql-client
  3. apt-get install apache2
  4. apt-get install php5 libapache2-mod-php5
  5. apt-cache search php5选择您需要的并像这样安装它们: apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
  6. apt-get install phpmyadmin
  7. service apache2 restart
  8. 然后打开 http://127.0.0.1/phpmyadmin/

These upper commands will make your xampp server. It will resolve your problem quickly and worked very smoothly. thanks to related articles:

这些上层命令将使您的 xampp 服务器。它将快速解决您的问题并且工作非常顺利。感谢相关文章:

  1. Ubuntu 14.10 LAMP server tutorial with Apache 2, PHP 5 and MySQL (MariaDB)
  2. How do I change the root directory of an apache server?
  1. 使用 Apache 2、PHP 5 和 MySQL (MariaDB) 的 Ubuntu 14.10 LAMP 服务器教程
  2. 如何更改apache服务器的根目录?