【问题标题】:phpMyAdmin cannot connect to MySQL serverphpMyAdmin 无法连接到 MySQL 服务器
【发布时间】:2014-07-15 23:55:39
【问题描述】:

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

我已尝试遵循此http://www.ishaanrawat.com/solved-wampserver-1045-access-denied-for-user-rootlocalhost-using-password-no/ 指令,但我得到了同样的错误。

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

以下是错误:

MySQL 说:文档

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

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

【问题讨论】:

  • 我们能看到你的连接字符串吗?
  • @ThanosMarkou :我不确定连接字符串在哪里,您想查看这个文件 config.inc 吗?
  • 您使用的是哪个操作系统?是ubuntu吗?
  • 可以用root用户无密码在命令行连接数据库吗?
  • 我使用的是 Windows 7 @SanjayaPandey

标签: mysql phpmyadmin


【解决方案1】:

$cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'root';

使用默认的 mySQL 密码“root”,它对我有用!!

【讨论】:

    【解决方案2】:

    解决办法是:

    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. 现在保存文件(如果无法保存则写入):

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

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

    祝你好运!

    【讨论】:

      【解决方案3】:

      转到 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'] = '';
      

      【讨论】:

        【解决方案4】:

        删除 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 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/

        这些上层命令将使您的 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?

        【讨论】:

          【解决方案5】:

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

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

            $cfg['Servers'][$i]['user'] = 'root';
            $cfg['Servers'][$i]['password'] = '';
            /* 服务器参数 /
            $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。 希望它现在有效!

          【讨论】:

            【解决方案6】:

            您可以观看以解决您的问题
            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;
            

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

            【讨论】:

            • auth_type 更改为 cookie 并显示登录表单。但仍然无法使用root用户登录。
            【解决方案7】:

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

            【讨论】:

            • 在config.inc.php中你应该定义你在mysql中为root用户设置的“密码”。
            猜你喜欢
            • 2014-03-13
            • 2017-03-10
            • 2013-02-28
            • 2012-12-01
            • 2015-05-10
            • 2012-11-03
            相关资源
            最近更新 更多