简体   繁体   English

mysql密码在终端中工作,但不在phpMyAdmin中?

[英]mysql password works in Terminal, but not in phpMyAdmin?

I can log in to mysql through Terminal using 我可以通过终端使用登录到mysql

mysql -u root -p

I'm prompted with: 我被提示:

Enter password:

When I enter the password I get: 当我输入密码时,我得到:

Welcome to the MySQL monitor....

However, when I try to user the same username/password combination into phpMyAdmin I get the rror: 但是,当我尝试将相同的用户名/密码组合用于phpMyAdmin时,我得到了rror:

#2002 Cannot log in to the MySQL server

Note: I am using Snow Leopard 注意:我正在使用Snow Leopard

I think that either the root is disabled by default on remote host (considering that your mysql server and your http server are on different host), or the remote root password is different from the one on localhost (same reason). 我认为默认情况下远程主机上的root被禁用(考虑到你的mysql服务器和你的http服务器在不同的主机上),或者远程root密码与localhost上的密码不同(同样的原因)。 It would be a way better to create a new admin user rather than using root remotely (the new username is obviously less easy to guess). 这将是一种更好的方式来创建一个新的管理员用户而不是远程使用root(新的用户名显然不太容易猜到)。

Because I am in Snow Leopard, I had to do the following. 因为我在Snow Leopard,所以我必须做以下事情。

Open Terminal 开放式终端

cd /etc/
sudo nano php.ini // or php.ini.default
Password: (enter my password)

And replace var/mysql/mysql.sock with the following: 并使用以下内容替换var / mysql / mysql.sock:

pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

Then in Terminal 然后在终端

sudo apachectl restart

It might happen when, there is no controluser configured for phpMyAdmin in your database. 它可能会发生时,有没有在你的数据库配置phpMyAdmin的控制用户

By default it is like below from config file. 默认情况下,它就像下面的配置文件。

$cfg['Servers'][$i]['controluser'] = 'pma';

You can also check existing database users by following query: 您还可以通过以下查询检查现有数据库用户:

select * from mysql.user;

Wish it will help. 希望它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM