phpMyAdmin 抛出 #2002 无法登录 mysql 服务器 phpmyadmin
我已经在本地计算机上安装了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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(27)
如果您在登录 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 editingphpmyadmin/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
这是旧的,但因为这是谷歌的第一个结果,
我通过在 SSH 中使用以下命令重新启动 MySQL 服务器来修复此问题:
/etc/init.d/mysql restart
(命令适用于 CentOS/CPanel 服务器) )
This is old but as it is the first result in Google,
I fixed this by simply restarting MySQL Server using:
/etc/init.d/mysql restart
in SSH (Command is for a CentOS/CPanel server)
背景:
我使用的是 Linux Mint 13。就我而言,当我重新启动计算机并且我的 DHCP 向我的桌面分配新的本地 IP 地址(从 192.168.0.2 到 192.168.0.4)时,会发生此错误。
更新
至此
解决了问题。享受。
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.
Update
to
This fixed the problem. Enjoy.
如果您在完成设置脚本后忘记将 config.inc.php 移动到正确的位置(就像我所做的那样),也可能会导致这种情况。
创建 config 文件夹并执行 chmod o+rw config 并转到 localhost/phpmyadmin/setup 并按照这些步骤操作后,您需要转到返回命令行并完成操作:
请参阅 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 doingchmod o+rw config
and going tolocalhost/phpmyadmin/setup
and following those steps, you need to go back to the command line and finish things off:See full instructions at https://phpmyadmin.readthedocs.org/en/latest/setup.html
尝试了上述所有建议后,这里修复了我的 #2002 错误。
将以下行添加到您的 config.inc.php 文件中,并将数字更改为您的 MySQL 端口:
我安装了多个 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:
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.
你的机器上安装了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).
我基本上已经浏览了所有的 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
我也经历过同样的事情,希望对你有帮助。
请登录访问mysql和phpmyadmin
I have also experienced the same thing, hopefully a this helps.
please login to access mysql and phpmyadmin
当我更改 AWS 服务器的实例类型时,就发生了这种情况。
#2002 无法登录 MySQL 服务器
也可能在mysqld
服务未启动时发生。所以首先你需要执行:
这会给你:
之后错误就不会出现。
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 themysqld
service is not started.So first of all you need to execute :
This will give you :
After that the error will not come.
P.S. On EC2 instances, one should also change the host from
localhost
to127.0.0.1
as mentioned in the top answer.现在,您应该能够登录 phpMyAdmin。
Now, you should be able log in to phpMyAdmin.
在使用 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.
在我的系统中,
config.inc.php
不存在,但config.sample.inc.php
存在。尝试将示例脚本复制到config.inc.php
In my system,
config.inc.php
didn't exist, butconfig.sample.inc.php
existed. Try copying the sample script toconfig.inc.php
我们的设置中多次遇到此问题,因此我制作了一个检查清单。
这假设您希望 phpMyAdmin 使用 UNIX 套接字而不是 TCP/IP 在本地连接到 MySQL。
UNIX 套接字应该稍微快一些,因为它们的开销更少,并且更安全,因为它们只能在本地访问。
服务
service mysqld status
service mysqld start
service mysqld restart
MySQL Config (my.cnf)
protocol =tcp
PHP Config (php.ini)
如果您可以从命令行本地连接,但是不是来自 phpMyAdmin,并且套接字文件不在默认位置:
mysqli.default_socket = *location*
pdo_myql .default_socket
和mysql.default_socket
只是为了确保service httpd restart
phpMyAdmin Config (config.inc.php)
$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
service mysqld status
service mysqld start
service mysqld restart
MySQL Config (my.cnf)
protocol=tcp
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:
mysqli.default_socket = *location*
pdo_myql.default_socket
andmysql.default_socket
just to be sureservice httpd restart
phpMyAdmin Config (config.inc.php)
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['socket'] = '*location*';
N.B.
As pointed out by @chk; Setting the
$cfg['Servers'][$i]['host']
fromlocalhost
to127.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
.对于 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
在 ubuntu 操作系统中的 '/etc/php5/apache2/php.ini' 文件中进行以下配置 这个页面说。
In ubuntu OS in '/etc/php5/apache2/php.ini' file do configurations that this page said.
对于那些在 Windows 计算机上使用 WAMP/XAMP 时遇到此错误的人。
这可能对你有帮助。
您的解决方案是
文件扩展名是.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
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
警告:此方法完全删除MySQL数据!
我在Ubuntu 12.10、mysql 5.5中遇到同样的问题
我已经测试了很多与我的问题相关的答案,但
最后没有一个主题工作我不得不重新安装删除我的mysql服务器完全然后我再次安装Mysql服务器
但是你应该知道你应该删除所有与Mysql相关的目录
我使用此链接完全删除mysql
,然后您通过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
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
经过多次尝试修复此问题后,发现问题在于 Mysql 用户不允许登录
如果它正在侦听所有接口,那么您可以将任何接口分配给此
尝试使用上述 IP 登录命令行
如果这有效,那么你的 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
If it is listening on all interfaces, then you can assign any of your interfaces to this
Try to Login using the above IP using the comand line
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.
右键单击我的电脑->管理->服务
从右侧窗格中选择“服务和应用程序”下的“服务”
然后搜索“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
检查您的服务器是否正在运行。
Check whether you server is running or not.
这是因为您的系统安装了两个“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!
以防万一有人遇到麻烦,这是一个非常确定的解决方案。
检查您的 etc/hosts 文件,确保每个主机都有一个 root 用户。
因此
,我将有 2 个或更多用户作为 mysql 的 root:
这就是我解决问题的方法。
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.
Therefore I will have 2 or more users as root for mysql:
this is how I fixed my problem.
对我来说,问题是通过删除以我的计算机命名的 .pid 文件解决的:
For me the problem was solved by deleting a .pid file named after my computer:
行
php.ini 文件中的以下
This the following line in your php.ini file
to
当您的计算机上已经安装了 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.我在 Windows 7 注册表中遇到 MySQL 服务路径问题
新安装的 XAMPP 或更新的 easyPHP 没有改变
版本。
因此,如果有人遇到同样的问题(#2002 错误,phpMyAdmin 无法
开始)你可以在 win regedit 中搜索“my.ini”并交换
新包的路径。
例如,我在几个地方交换了旧路径:
与较新的:
奇怪的是,之前没有人在网络上描述过这个问题!
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:
with the newer one:
It is strange that nobody described this issue before on the web!
我的问题通过这一步解决了
my problem is solved by this step