#2002 无法登录 MySQL 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17733678/
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
#2002 Cannot log in to the MySQL server
提问by Shredder2500
I am working on a windows server 2012 and trying to get PHPMyAdmin working. I cant get it to connect to the MySQL by root user or a non root user. I have searched and searched all over google. everywhere I saw it said to set allowroot and change localhost to 127.0.0.1 in the config.inc.php file. At first I could not find this file but then I read you have to change config.default.php to it and put it in the root folder. I did that. and here is what I changed
我正在 Windows Server 2012 上工作并试图让 PHPMyAdmin 工作。我无法让它通过 root 用户或非 root 用户连接到 MySQL。我已经在谷歌上搜索并搜索了所有内容。我在任何地方都看到它说要在 config.inc.php 文件中设置 allowroot 并将 localhost 更改为 127.0.0.1。起初我找不到这个文件,但后来我读到你必须将 config.default.php 更改为它并将其放在根文件夹中。我就是这么做的。这是我改变的
$cfg['Servers'][$i]['host'] = "127.0.0.1"
//already had the next one set
$cfg['Servers'][$i]['AllowRoot'] = true
I still cant get it to login from any user on MySQL, and I keep getting the error
我仍然无法从 MySQL 上的任何用户登录,而且我不断收到错误消息
#2002 Cannot log in to the MySQL server.
config.inc.php: http://u16626886.onlinehome-server.com/config.inc.zip
config.inc.php:http: //u16626886.onlinehome-server.com/config.inc.zip
Testing PHP and MySQL: http://u16626886.onlinehome-server.com:801/test.php
测试 PHP 和 MySQL:http: //u16626886.onlinehome-server.com: 801/test.php
I figured out the problem just need to solve it now. If I put MySQL on the C: drive it works fine but if I put it on the D: drive, which is where I want it, PHP can not connect to it. Does anyone know why that is?
我想出了这个问题,现在只需要解决它。如果我将 MySQL 放在 C: 驱动器上它可以正常工作,但如果我将它放在 D: 驱动器上,这是我想要的位置,PHP 无法连接到它。有谁知道这是为什么?
回答by Johnbosco Adam
It may be Mysql service is not running, try to start Mysql service
Sometimes Mysql Service May Not Run..
Try the following
1. Remove/Unstall the service
a) Start Cmd As Administrator
b) Type Mysql --remove
2. Restart Pc
3. Install
a) Start Cmd As Administrator
b) Use Cd ../ To locate the path for Mysqld (For me it is in C:\xampp\mysql\bin)
c)Type mysqld --Install
4. Restart Pc
回答by user3850398
This was solved my problem on mac.
这在mac上解决了我的问题。
-config.inc.php-
-config.inc.php-
change
改变
$cfg['Servers'][$i]['AllowNoPassword'] = false;
to
到
$cfg['Servers'][$i]['AllowNoPassword'] = true;
and then,
进而,
-go to terminal -
- 前往终端 -
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
and then come back and reloaded page.
然后回来重新加载页面。
回答by Debasis Sabat
This is a 2002 MySQL Socket error, we can resolve this quickly by executing following command
这是一个 2002 MySQL Socket 错误,我们可以通过执行以下命令快速解决这个问题
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Note: Above path is based on MAC, so you can change the path according to your OS
注意:以上路径是基于MAC的,因此您可以根据您的操作系统更改路径
回答by Nishchit Dhanani
Run SKYPE then using the menus do this:
运行 SKYPE,然后使用菜单执行以下操作:
Tools -> Options -> Advanced -> Connection
工具 -> 选项 -> 高级 -> 连接
Un-Check the checkbox next to 'Use port 80 and 443 as alternatives for incomming connections'
取消选中“使用端口 80 和 443 作为传入连接的替代选项”旁边的复选框
Now restart SKYPE for these changes to take effect.
现在重新启动 SKYPE 以使这些更改生效。