phpmyadmin #1045 无法登录 MySQL 服务器。安装mysql命令行客户端后
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20887507/
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
phpmyadmin #1045 Cannot log in to the MySQL server. after installing mysql command line client
提问by black
I installed wamp.phpmyadmin working fine. Now that I have installed mysql command line client I am not able to connect to my databases from mysql command line or phpmyadmin. After restarting I could not access phpmyadmin #1045 Cannot log in to the MySQL server
. In addition to that my mysql command line not accepting my password and rejects my config files:
我安装了 wamp.phpmyadmin 工作正常。现在我已经安装了 mysql 命令行客户端,我无法从 mysql 命令行或 phpmyadmin 连接到我的数据库。重新启动后,我无法访问 phpmyadmin #1045 Cannot log in to the MySQL server
。除此之外,我的 mysql 命令行不接受我的密码并拒绝我的配置文件:
C:\wamp\bin\mysql\mysql5.5.24
my.ini
我的.ini
port=3306
my config.inc.php
我的 config.inc.php
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'whtevr';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
httpd.conf
配置文件
listen port:80
C:\Program Files\MySQL\MySQL Server 5.0
C:\Program Files\MySQL\MySQL Server 5.0
my.ini
我的.ini
port:3306
Again, I reinstalled mysql command line with port changed to 3307
再次,我重新安装了 mysql 命令行,端口更改为 3307
port:3307
WAMP works fine accessing all the databases but from mysql command line client I could not access all my databases. It is only showing show databases;
WAMP 可以正常访问所有数据库,但是从 mysql 命令行客户端我无法访问我的所有数据库。它只是显示show databases;
information_schema
mysql
test
回答by JGutierrezC
In case MySQL Server is up but you are still getting the error:
如果 MySQL 服务器已启动但您仍然收到错误消息:
For anyone who still have this issue, I followed awesome tutorial http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-9-mavericks/
对于仍然有这个问题的人,我遵循了很棒的教程http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-9-mavericks/
However i still got #1045 error.
What really did the trick was to change localhost
to 127.0.0.1
at your config.inc.php
. Why was it failing if locahost points to 127.0.0.1? I don't know. But it worked.
但是我仍然遇到#1045 错误。真正的伎俩是改变localhost
到127.0.0.1
你config.inc.php
。如果 locahost 指向 127.0.0.1,为什么会失败?我不知道。但它奏效了。
===== EDIT =====
===== 编辑 =====
Long story short, it is because of permissions in mysql. It may be set to accept connections from 127.0.0.1 but not from localhost.
长话短说,这是因为mysql中的权限。它可以设置为接受来自 127.0.0.1 的连接,但不接受来自 localhost 的连接。
The actual answer for why this isn't responding is here: https://serverfault.com/a/297310
为什么没有响应的实际答案在这里:https: //serverfault.com/a/297310
回答by micmia
I was experiencing the same problem on OS X. I've solved it now. I post my solution here for anyone who has the similar issue.
我在 OS X 上遇到了同样的问题。我现在已经解决了。我在这里为任何有类似问题的人发布我的解决方案。
Firstly, I set the password for root in mysql
client:
首先,我在mysql
客户端为root设置密码:
shell> mysql -u root
mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MY_PASSWORD');
Then, I checked the version info:
然后,我检查了版本信息:
shell> /usr/local/mysql/bin/mysqladmin -u root -p version
...
Server version 5.6.26
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 11 min 0 sec
...
Finally, I changed the connect_type
parameter from tcp
to socket
and added the parameter socket
in config.inc.php
:
最后,我改变了connect_type
从参数tcp
到socket
并添加参数socket
在config.inc.php
:
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
回答by Ares
If you reinstalled the server it means that that the new installation most likely overwrote your username and passwords. (You might want to try loggin without a password see if it works).
如果您重新安装了服务器,则意味着新安装很可能覆盖了您的用户名和密码。(您可能想尝试在没有密码的情况下登录,看看它是否有效)。
If it is a clean install you need to set the root password.
如果是全新安装,则需要设置 root 密码。
Otherwise, you will need to reset root permissions.
否则,您将需要重置 root 权限。
回答by apricot boy
I just solved this error for myself, but it was a bit silly on my part. Still worth checking if the above doesn't help you.
我刚刚为自己解决了这个错误,但这对我来说有点傻。如果上述内容对您没有帮助,仍然值得检查。
In my case, I was editing the config files in /etc/phpmyadmin
, my install was located in /usr/share/phpmyadmin
, and my install was not actually opening the /etc/phpmyadmin
config files, as I thought it would. So I just did this command:
就我而言,我在 中编辑配置文件/etc/phpmyadmin
,我的安装位于 中/usr/share/phpmyadmin
,而我的安装实际上并没有/etc/phpmyadmin
像我想象的那样打开配置文件。所以我只是做了这个命令:
ln -s /etc/phpmyadmin/conf* /usr/share/phpmyadmin
ln -s /etc/phpmyadmin/conf* /usr/share/phpmyadmin
For those not in the know, ln -s
makes a soft link (basically a shortcut). So that command just makes shortcuts from the config files in /etc
to the /usr/share
install.
对于那些不知道的人,ln -s
制作一个软链接(基本上是一个快捷方式)。所以该命令只是从配置文件/etc
到/usr/share
安装的快捷方式。
By the way, I figured this out after using the program opensnoop
, which shows you what files are being opened (technically, traces open()
syscalls and the pid of the process, as they happen), which you can install on Ubuntu with apt-get install perf-tools-unstable
, or you can get it here.
顺便说一句,我在使用该程序后发现了这一点,该程序opensnoop
向您显示正在打开哪些文件(从技术上讲,跟踪open()
系统调用和进程的 pid,当它们发生时),您可以使用 安装在 Ubuntu 上apt-get install perf-tools-unstable
,或者您可以获得它在这里。
回答by Meshack Mbuvi
After like three (3) hours of google..ing.This is the solution to the problem: First, I run this command;
经过三 (3) 个小时的 google..ing.这是问题的解决方案:首先,我运行此命令;
$mysqladmin -u root -p[your root password here] version
Which outputs:
$mysqladmin -u root -p[your root password here] version
哪些输出:
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.5.49-0ubuntu0.14.04.1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 1 hour 54 min 3 sec
Finally, I changed the connect_type
parameter from tcp
to socket
and added the parameter socket
in config.inc.php
:
最后,我改变了connect_type
从参数tcp
到socket
并添加参数socket
在config.inc.php
:
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['socket'] = '/var/run/mysqld/mysqld.sock';
All credit goes to this person: This is the correct solution
所有功劳都归功于此人: 这是正确的解决方案
回答by u3968246
I also had this error. It worked normally after I clean up the cookies.
我也有这个错误。我清理饼干后它正常工作。
回答by Mike Przybylski
You have to go into your mySQL settings and change the settings to Legacy authentication. I use mysql community installer and it allows you to go back and reconfigure the settings. Create a new user, and choose standard authentication, choose a password, thats it. Its that simple!!!
您必须进入 mySQL 设置并将设置更改为 Legacy 身份验证。我使用 mysql 社区安装程序,它允许您返回并重新配置设置。创建一个新用户,然后选择标准身份验证,选择一个密码,就是这样。就这么简单!!!
回答by Tanmoy Kundu
I would suggest 3 things:
我会建议三件事:
- First try clearing browser's cache
- Try to assign username & password statically into config.inc.php
- Once you've done with installation, delete the config.inc.php file under "phpmyadmin" folder
- 首先尝试清除浏览器的缓存
- 尝试将用户名和密码静态分配到 config.inc.php
- 安装完成后,删除“phpmyadmin”文件夹下的 config.inc.php 文件
The last one worked for me.
最后一个对我有用。
回答by Yohanip
Adding the following $cfg helps to narrow down the problem
添加以下 $cfg 有助于缩小问题的范围
$cfg['Error_Handler']['display'] = true;
$cfg['Error_Handler']['gather'] = true;
Don't forgetto remove those $cfg after done debugging!
完成调试后不要忘记删除那些 $cfg !
回答by bytecode77
I also had this error once, but only with one specific user. So what I did is remove the user and re-create it with the same name and password.
我也有一次这个错误,但只有一个特定的用户。所以我所做的是删除用户并使用相同的名称和密码重新创建它。
Then after I re-imported the database, it worked.
然后在我重新导入数据库后,它起作用了。