phpMyAdmin 抛出 #2002 无法登录 mysql 服务器 phpmyadmin

发布于 2024-09-18 23:33:28 字数 283 浏览 6 评论 0原文

我已经在本地计算机上安装了MySQL服务器企业版5.1,现在我想安装phpMyAdmin,但它不起作用。

我已将 phpMyAdmin 解压到我的服务器根目录并浏览到“localhost/phpMyAdmin/setup/index.php”,启动了一个新服务器,我更改的唯一设置是在“配置验证密码”字段中填写我的 MySQL 密码,

所以现在,当我尝试登录时,收到一条错误消息:“#2002 无法登录 mysql 服务器 phpmyadmin”

有谁知道出了什么问题吗?从昨天开始我就一直遇到这个问题。

I have installed MySQL server enterprise 5.1 on my local machine and now I want to install phpMyAdmin, but it does not work.

I have unrared phpMyAdmin to my server root directory and browsed to "localhost/phpMyAdmin/setup/index.php", started a new server and the only setting I changed was filling in my MySQL password in the field "Password for config auth"

So now when I am trying to log in I get an error message saying "#2002 cannot log in to the mysql server phpmyadmin"

Does anyone know what's wrong? I've been having this problem since yesterday.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(27

一江春梦 2024-09-25 23:33:28

如果您在登录 phpmyadmin 时遇到 #2002 Cannot log in to the MySQL server 错误,请尝试编辑 phpmyadmin/config.inc.php 并更改:

$cfg['Servers'][$i]['host'] = 'localhost';

到:

$cfg['Servers'][$i]['host'] = '127.0 .0.1';

来自 Ryan 的博客

编辑(2015 年 3 月 20 日):

请注意,如果您是全新安装,config.inc.php 可能不存在。您需要重命名/复制config.sample.inc.php,然后更改相关行

If you're getting the #2002 Cannot log in to the MySQL server error while logging in to phpmyadmin, try editing phpmyadmin/config.inc.php and change:

$cfg['Servers'][$i]['host'] = 'localhost';

to:

$cfg['Servers'][$i]['host'] = '127.0.0.1';

Solution from Ryan's blog

Edit (20-Mar-2015):

Note that if you're on a fresh install, config.inc.php may not exist. You need to rename / copy config.sample.inc.php and then change the relevant line

我的奇迹 2024-09-25 23:33:28

这是旧的,但因为这是谷歌的第一个结果,

请注意,当您的 MySql 服务关闭时也会发生这种情况,

我通过在 SSH 中使用以下命令重新启动 MySQL 服务器来修复此问题:

/etc/init.d/mysql restart

(命令适用于 CentOS/CPanel 服务器) )

This is old but as it is the first result in Google,

Please note that this also happens when your MySql service is down,

I fixed this by simply restarting MySQL Server using:

/etc/init.d/mysql restart

in SSH (Command is for a CentOS/CPanel server)

素年丶 2024-09-25 23:33:28

背景:
我使用的是 Linux Mint 13。就我而言,当我重新启动计算机并且我的 DHCP 向我的桌面分配新的本地 IP 地址(从 192.168.0.2 到 192.168.0.4)时,会发生此错误。

sudo gedit /etc/mysql/my.cnf

更新

bind-address = 192.168.0.2

至此

bind-address = localhost

解决了问题。享受。

Background:
I am using Linux Mint 13. In my case, this error happened when I restarted the computer and my DHCP assigned a new local IP address (from 192.168.0.2 to 192.168.0.4) to my desktop.

sudo gedit /etc/mysql/my.cnf

Update

bind-address = 192.168.0.2

to

bind-address = localhost

This fixed the problem. Enjoy.

小苏打饼 2024-09-25 23:33:28

如果您在完成设置脚本后忘记将 config.inc.php 移动到正确的位置(就像我所做的那样),也可能会导致这种情况。

创建 config 文件夹并执行 chmod o+rw config 并转到 localhost/phpmyadmin/setup 并按照这些步骤操作后,您需要转到返回命令行并完成操作:

mv config/config.inc.php .         # move file to current directory
chmod o-rw config.inc.php          # remove world read and write permissions
rm -rf config                      # remove not needed directory

请参阅 https://phpmyadmin.readthedocs 中的完整说明.org/en/latest/setup.html

This can also be caused if you forget (as I did) to move config.inc.php into its proper place after completing the setup script.

After making the config folder and doing chmod o+rw config and going to localhost/phpmyadmin/setup and following those steps, you need to go back to the command line and finish things off:

mv config/config.inc.php .         # move file to current directory
chmod o-rw config.inc.php          # remove world read and write permissions
rm -rf config                      # remove not needed directory

See full instructions at https://phpmyadmin.readthedocs.org/en/latest/setup.html

虚拟世界 2024-09-25 23:33:28

尝试了上述所有建议后,这里修复了我的 #2002 错误。

将以下行添加到您的 config.inc.php 文件中,并将数字更改为您的 MySQL 端口:

$cfg['Servers'][$i]['port'] = '3307'; // MySQL port

我安装了多个 mysql 实例,在本例中,我已更新 my.ini 以在端口 3307 上运行 MySQL,但尚未更新phpMyAdmin 以反映新端口。就我而言,config.inc.php 文件中不存在该端口的行,因此我不知道它需要更新。

After trying all of the above suggestions here is what fixed my #2002 error.

Add the following line to your config.inc.php file and change the number to your MySQL port:

$cfg['Servers'][$i]['port'] = '3307'; // MySQL port

I had multiple mysql instances installed, and in this case, I had updated my.ini to run MySQL on port 3307, but had not updated phpMyAdmin to reflect the new port. In my case, the line for the port did not exist in the config.inc.php file, so I was not aware that it needed updating.

我的黑色迷你裙 2024-09-25 23:33:28

你的机器上安装了MySQL吗?听起来您使用的是 Windows; MySQL 作为“服务”在您的计算机上运行(右键单击“我的电脑”->“管理”->“服务”)。

Did you set up the MySQL on your machine? It sounds like you're using Windows; MySQL runs as a "Service" on your machine (right-click My Computer -> Manage -> Services).

℉服软 2024-09-25 23:33:28

我基本上已经浏览了所有的 stackoverflow 来解决这个错误,但没有解决我的问题。我可以直接从linux命令行登录mysql,但是使用相同的用户和密码无法登录phpmyadmin。

所以我把头撞在墙上半天,直到我意识到它甚至没有读取 /etc/phpmyadmin 下的 config.inc.php (顺便说一句,它是基于“find / -iname config.inc”找到的唯一位置) .php”。所以我更改了 /usr/share/phpMyAdmin/libraries/config.default.php 中的主机,它终于起作用了。

我知道可能还有另一个问题,为什么它不从 /etc/phpmyadmin 读取配置文件夹,但我现在不能为此烦恼:P

tldr; 如果您的设置似乎根本不适用,请尝试在 /usr/share/phpMyAdmin/libraries/config.default.php 中进行更改

I've been through basically all of stackoverflow for this error and nothing resolved my issue. I was able to log into mysql directly from the linux command line fine, but with the same user and password couldn't log into phpmyadmin.

So I beat my head against the wall for half the day until I realized it wasn't even reading the config.inc.php under /etc/phpmyadmin (the only place it was located btw based on "find / -iname config.inc.php". So I changed the host in /usr/share/phpMyAdmin/libraries/config.default.php and it finally worked.

I know there's probably another issue with why it isn't reading the config from the /etc/phpmyadmin folder but I can't be bothered with that for now :P

tldr; if your settings don't seem to be applying at all try making the changes within /usr/share/phpMyAdmin/libraries/config.default.php

舂唻埖巳落 2024-09-25 23:33:28

我也经历过同样的事情,希望对你有帮助。

cd /etc/init.d
./mysql start

请登录访问mysql和phpmyadmin

I have also experienced the same thing, hopefully a this helps.

cd /etc/init.d
./mysql start

please login to access mysql and phpmyadmin

无戏配角 2024-09-25 23:33:28

当我更改 AWS 服务器的实例类型时,就发生了这种情况。

#2002 无法登录 MySQL 服务器 也可能在 mysqld 服务未启动时发生。

所以首先你需要执行:

$ sudo service mysqld restart

这会给你:

$ sudo service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

之后错误就不会出现。

PS 在 EC2 实例上,还应该将主机从 localhost 更改为 127.0.0.1,如最上面的答案中所述。

It happened with me when I changed the instance type of my AWS server.

#2002 Cannot log in to the MySQL server can also occur when the mysqld service is not started.

So first of all you need to execute :

$ sudo service mysqld restart

This will give you :

$ sudo service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

After that the error will not come.

P.S. On EC2 instances, one should also change the host from localhost to 127.0.0.1 as mentioned in the top answer.

大姐,你呐 2024-09-25 23:33:28
  • 右键单击我的电脑->管理->服务
  • 从右侧窗格中的“服务和应用程序”下选择“服务”,
  • 然后搜索“Zend Development”服务。
  • 找到它后,双击启动该服务。

现在,您应该能够登录 phpMyAdmin。

  • Right-click My Computer -> Manage -> Services
  • Choose "Services" under the "Services and Application" from right pane
  • Then search for the "Zend Development" Service.
  • When you find it, double click to start that service.

Now, you should be able log in to phpMyAdmin.

街角卖回忆 2024-09-25 23:33:28

在使用 DDoS(实际上是渗透测试工具)攻击服务器后,我遇到了同样的问题。

我首先前往 /etc/var/mysql/error.log 查看 InnoDB 有文件锁。

通过重新启动服务器立即解决了该问题,但这并不是面向未来的。

I had same issue after the server has been attacked using a DDoS (actually a penetration testing tool).

I've headed to /etc/var/mysql/error.log first to see the InnoDB had a file lock.

The issue was immediately fixed by restarting the server, however that's not future-proof.

一花一树开 2024-09-25 23:33:28

在我的系统中,config.inc.php不存在,但config.sample.inc.php存在。尝试将示例脚本复制到 config.inc.php

In my system, config.inc.php didn't exist, but config.sample.inc.php existed. Try copying the sample script to config.inc.php

牵强ㄟ 2024-09-25 23:33:28

我们的设置中多次遇到此问题,因此我制作了一个检查清单。

这假设您希望 phpMyAdmin 使用 UNIX 套接字而不是 TCP/IP 在本地连接到 MySQL。

UNIX 套接字应该稍微快一些,因为它们的开销更少,并且更安全,因为它们只能在本地访问。

服务

  • mysqld 服务是否正在运行? service mysqld status
  • .. 如果不是 service mysqld start
  • 自服务启动以来配置是否已更改? service mysqld restart

MySQL Config (my.cnf)

  • 检查是否存在非套接字客户端协议集,例如 protocol =tcp
  • 检查套接字位置是否可访问并具有正确的权限

PHP Config (php.ini)

如果您可以从命令行本地连接,但是不是来自 phpMyAdmin,并且套接字文件不在默认位置:

  • 将 mysqli 默认套接字设置为新位置:mysqli.default_socket = *location*
  • ...我还设置了 pdo_myql .default_socketmysql.default_socket 只是为了确保
  • 重新启动您的 Web 服务(在我的例子中为 httpd)service httpd restart

phpMyAdmin Config (config.inc.php)

  • 检查主机是否设置为 localhost:$cfg['Servers'][$i]['host'] = 'localhost';
  • 套接字位置也可以在此处设置: $cfg['Servers'][$i]['socket'] = '*location*';

NB

正如所指出的由@chk发出;将 $cfg['Servers'][$i]['host']localhost 设置为 127.0.0.1 只会导致连接到使用 TCP/IP 而不是使用套接字,这更多的是一种解决方法而不是解决方案。

MySQL 配置设置 bind-address= 也仅影响 TCP/IP 连接。

如果不需要远程连接,建议使用 skip-networking 关闭 TCP/IP 监听。

Had this problem a number of times on our setup, so I've made a check list.

This assumes you want phpMyAdmin connecting locally to MySQL using a UNIX socket rather than TCP/IP.

UNIX sockets should be slightly faster as they have less overhead and can be more secure as they can only be accessed locally.

Service

  • Is the mysqld service running? service mysqld status
  • .. If not service mysqld start
  • Has config has changed since service started? service mysqld restart

MySQL Config (my.cnf)

  • Check that there isn't a non-socket client protocol set, e.g. protocol=tcp
  • Check that the socket location is accessible and has the right permissions

PHP Config (php.ini)

If you can connect locally from the command line, but not from phpMyAdmin, and the socket file is not in the default location:

  • Set the mysqli default sockets to the new location: mysqli.default_socket = *location*
  • ... I also set the pdo_myql.default_socket and mysql.default_socket just to be sure
  • Restart your web service (httpd in my case) service httpd restart

phpMyAdmin Config (config.inc.php)

  • Check that the host is set to localhost: $cfg['Servers'][$i]['host'] = 'localhost';
  • The socket location can also be set here: $cfg['Servers'][$i]['socket'] = '*location*';

N.B.

As pointed out by @chk; Setting the $cfg['Servers'][$i]['host'] from localhost to 127.0.0.1 just causes the connection to use TCP/IP rather than using the socket and is more of a workaround than a solution.

The MySQL config setting bind-address= also only affects TCP/IP connections.

If you don't need remote connections, it is recommended to turn off TCP/IP listening with skip-networking.

卖梦商人 2024-09-25 23:33:28

对于 Ubuntu 14.04 和 16.04,您可以应用以下命令

检查 MySQL 服务是否正在运行

首先,使用sudo service mysql status

现在您可以看到显示如下消息: mysql stop/waiting

现在应用命令:sudo service mysql restart

现在您可以看到显示如下消息:mysql start/running, process 8313。

现在转到浏览器并以 root(用户名) 和 root(密码) 身份登录,您将成功登录

For Ubuntu 14.04 and 16.04, you can apply following commands

First, check MySQL service is running or not using

sudo service mysql status

Now you can see you show a message like this: mysql stop/waiting.

Now apply command: sudo service mysql restart!

Now you can see you show a message like this: mysql start/running, process 8313.

Now go to the browser and logged in as root(username) and root(password) and you will be logged in successfully

︶葆Ⅱㄣ 2024-09-25 23:33:28

在 ubuntu 操作系统中的 '/etc/php5/apache2/php.ini' 文件中进行以下配置 这个页面说。

In ubuntu OS in '/etc/php5/apache2/php.ini' file do configurations that this page said.

冷情 2024-09-25 23:33:28

对于那些在 Windows 计算机上使用 WAMP/XAMP 时遇到此错误的人。

这可能对你有帮助。

您的解决方案是

  • net stop mysql
  • 擦除二进制日志(以及二进制日志索引文件)
  • 如果您不知道它们在哪里,请在 PC 上找到 my.ini
  • 在记事本中打开 my.ini 查找选项 log-bin 或 log_bin
  • 查找对于选项 datadir
  • 如果 log-bin 只有文件名,则查看 datadir 指定的文件夹
  • 如果 log-bin 包含路径和文件名,则查看 log-bin 指定的文件夹
  • 在 Windows 资源管理器中打开所需的文件夹
  • 删除二进制文件日志 应该有一个文件,其
    文件扩展名是.index。也删除它 net start mysql

当您遇到二进制日志问题时,请不要删除 ib_logfile0 或 ib_logfile1。

答案位于 dba.stackexchange

For those who get this error when working with WAMP/XAMP on a windows machine.

This may help you.

Your solution is to

  • net stop mysql
  • Erase binary logs (and the binary log index file)
  • IF you do not know where they are, locate my.ini on your PC
  • Open my.ini in Notepad look for the option log-bin or log_bin
  • Look for the option datadir
  • If log-bin only has a filename, look inside the folder specified by datadir
  • If log-bin includes a path and a filename, look inside the folder specified by log-bin
  • Open the desired folder in Windows Explorer
  • Remove the binary logs There should be a file whose
    file extension is .index. Delete this as well net start mysql

Please DO NOT ERASE ib_logfile0 or ib_logfile1 when you have binary log issues.

Answer is on dba.stackexchange

油饼 2024-09-25 23:33:28

警告:此方法完全删除MySQL数据!

我在Ubuntu 12.10、mysql 5.5中遇到同样的问题

我已经测试了很多与我的问题相关的答案,但

最后没有一个主题工作我不得不重新安装删除我的mysql服务器完全然后我再次安装Mysql服务器

但是你应该知道你应该删除所有与Mysql相关的目录
我使用此链接完全删除mysql

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/run/mysqld

,然后您通过taskel再次安装LAMP

完全删除MySQL 5.5

https://serverfault.com/questions/254629/无法在 ubuntu 中安装 mysql-server/296928#296928

CAUTION: This method completely removes MySQL data!

I have same problem in Ubuntu 12.10 , mysql 5.5

I have tested lots of answer related to my issue but none of theme work

at last I had to reinstall remove my mysql server completely and then I install again Mysql server

but you should be aware that you should delete all directory which related to Mysql
I use this link to remove mysql completely

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/run/mysqld

and then you install again LAMP by tasksel

Removing MySQL 5.5 Completely

https://serverfault.com/questions/254629/unable-to-install-mysql-server-in-ubuntu/296928#296928

凉薄对峙 2024-09-25 23:33:28

经过多次尝试修复此问题后,发现问题在于 Mysql 用户不允许登录

netstat -na | grep -i 3306

如果它正在侦听所有接口,那么您可以将任何接口分配给此

$cfg['Servers'][$i]['host'] = 'ANY INTERFACE';

尝试使用上述 IP 登录命令行

mysql -u bla -p -h <Above_IP_address>

如果这有效,那么你的 phpmyadmin 也将工作,如果没有修复 mysql.user 表,以便上述命令工作并允许你登录 mysql。

After Many attempts in getting this fixed, it was found out that the issue was with Mysql users not being allowed to login

netstat -na | grep -i 3306

If it is listening on all interfaces, then you can assign any of your interfaces to this

$cfg['Servers'][$i]['host'] = 'ANY INTERFACE';

Try to Login using the above IP using the comand line

mysql -u bla -p -h <Above_IP_address>

If this works then your phpmyadmin will also work, If not fix the mysql.user table so that the above command works and allows you to login to mysql.

绅刃 2024-09-25 23:33:28

右键单击我的电脑->管理->服务
从右侧窗格中选择“服务和应用程序”下的“服务”
然后搜索“mysql”服务。
找到它后,双击启动该服务。

现在您应该能够运行并登录 PhpMyAdmin

Right-click My Computer -> Manage -> Services
Choose "Services" under the "Services and Application" from right pane
Then search for the "mysql" Service.
When you find it, double click to start that service.

Now you should be able to run and login to PhpMyAdmin

又怨 2024-09-25 23:33:28

检查您的服务器是否正在运行。

Check whether you server is running or not.

两仪 2024-09-25 23:33:28

这是因为您的系统安装了两个“mysql”软件包。一种安装是通过 xampp/lampp 进行的,另一种安装是通过 mysql-debain 包进行的。要解决这个问题,只需进入“synaptic manager”并删除mysql,然后您就可以从xampp服务器访问mysql。

注意:从突触管理器中删除 mysql 不会影响通过 xampp/lampp 服务器安装的 mysql。所以不用担心!

It is because your system has two installations of "mysql" packages. One installation was made through xampp/lampp and another installation was made through mysql-debain package. To solve the problem, just go to "synaptic manager" and remove mysql, and then you will be able to access mysql from xampp server.

Note : removing mysql from synaptic manager doesn't affect mysql which was installed through xampp/lampp server. So don't worry!

白云悠悠 2024-09-25 23:33:28

以防万一有人遇到麻烦,这是一个非常确定的解决方案。

检查您的 etc/hosts 文件,确保每个主机都有一个 root 用户。

因此

127.0.0.1   home.dev

localhost   home.dev

,我将有 2 个或更多用户作为 mysql 的 root:

root@localhost
[email protected]

这就是我解决问题的方法。

Just in case anyone has anymore troubles, this is a pretty sure fix.

check your etc/hosts file make sure you have a root user for every host.

i.e.

127.0.0.1   home.dev

localhost   home.dev

Therefore I will have 2 or more users as root for mysql:

root@localhost
[email protected]

this is how I fixed my problem.

初懵 2024-09-25 23:33:28

对我来说,问题是通过删除以我的计算机命名的 .pid 文件解决的:

sudo rm /var/mysql/computername.pid

For me the problem was solved by deleting a .pid file named after my computer:

sudo rm /var/mysql/computername.pid
无言温柔 2024-09-25 23:33:28

mysql.default_socket = "MySQL"

php.ini 文件中的以下

mysql.default_socket = /var/run/mysqld/mysqld.sock

This the following line in your php.ini file

mysql.default_socket = "MySQL"

to

mysql.default_socket = /var/run/mysqld/mysqld.sock
向日葵 2024-09-25 23:33:28

当您的计算机上已经安装了 MySQL 或如果您更改了 MySql 服务的邮政编号(默认为 3306),则会出现此问题。为了解决此问题,您必须告诉phpMyAdmin 寻找另一个端口而不是 3306。为此,请转到 C:\xampp\phpMyAdmin(默认位置)并打开 Config.inc 并添加此行 $cfg[ '服务器'][$i]['端口'] = '3307'; $cfg['服务器'][$i]['AllowNoPassword'] = true;< /code> 重新启动服务,现在它应该可以工作了。

This problem occurs when you already had MySQL installed on your machine or in case you have changed the post number of the MySql service which is 3306(Default). In order to solve this, you have to tell the phpMyAdmin to look for another port instead of 3306. To do so go to C:\xampp\phpMyAdmin(default location) and open Config.inc and add this line $cfg['Servers'][$i]['port'] = '3307'; after $cfg['Servers'][$i]['AllowNoPassword'] = true; Restart the services and now it should work.

风吹短裙飘 2024-09-25 23:33:28

我在 Windows 7 注册表中遇到 MySQL 服务路径问题
新安装的 XAMPP 或更新的 easyPHP 没有改变
版本。

因此,如果有人遇到同样的问题(#2002 错误,phpMyAdmin 无法
开始)你可以在 win regedit 中搜索“my.ini”并交换
新包的路径。

例如,我在几个地方交换了旧路径:

C:\EASYPH~1.1VC\binaries\mysql\bin\eds-mysqld.exe
--defaults-file=C:\EASYPH~1.1VC\binaries\mysql\my.ini MySQL

与较新的:

c:\xampp\mysql\bin\mysqld.exe --defaults-file=c:\xampp\mysql\bin\my.ini
mysql

奇怪的是,之前没有人在网络上描述过这个问题!

I had an issue with the path of the MySQL service in the Windows 7 registry
which was not changed with the new installed XAMPP or newer easyPHP
version.

So if anybody has the same problem (#2002 error, phpMyAdmin cannot be
started) you can search into the win regedit for 'my.ini' and exchange the
path to the new package.

For example I exchanged on a few places the older path:

C:\EASYPH~1.1VC\binaries\mysql\bin\eds-mysqld.exe
--defaults-file=C:\EASYPH~1.1VC\binaries\mysql\my.ini MySQL

with the newer one:

c:\xampp\mysql\bin\mysqld.exe --defaults-file=c:\xampp\mysql\bin\my.ini
mysql

It is strange that nobody described this issue before on the web!

欢你一世 2024-09-25 23:33:28

我的问题通过这一步解决了

  1. apt-get install mysql-server phpmy admin
  2. /etc/init.d/mysql restart
  3. 完成。

my problem is solved by this step

  1. apt-get install mysql-server phpmy admin
  2. /etc/init.d/mysql restart
  3. done.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文