mysqli_real_connect(): (HY000/2002): No such file

2020-02-07 17:28发布

mysqli_real_connect(): (HY000/2002): No such file or directory

PhpMyAdmin error on MacOS. I want answer I really have no idea what I need to do to resolve this.

14条回答
聊天终结者
2楼-- · 2020-02-07 18:22

phpmyadmin 2018 October

Locate config.sample.inc.php

Change

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

into

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

Save.

Then rename file and remove sample from the name.

查看更多
仙女界的扛把子
3楼-- · 2020-02-07 18:22

I faced this problem on CentOS.

First I try this

sudo service mysql restart

Then error shows up

Redirecting to /bin/systemctl restart mysql.service
Failed to restart mysql.service: Unit not found.

Then I Found this

Command this solve my problem

systemctl start mariadb.service
查看更多
不美不萌又怎样
4楼-- · 2020-02-07 18:22

If you are using archlinux or Ubuntu just type the commands below:

$ cd /opt/lampp/phpmyadmin

then

$ sudo gedit config.inc.php

Then when you access the file look for the scripts below,

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

remove '//' so that it remains as shown below:

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

Then change the 'localhost' to '127.0.0.1' and the script should turn as shown below:

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

Get back to your browser and type http://127.0.0.1/phpmyadmin/

If it is still refusing

You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

so then get back to the same file config.inc.php you were editing and do as follows:

$ cd /opt/lampp/phpmyadmin

then

$ sudo gedit config.inc.php

search for the script below

$cfg['Servers'][$i]['password'] =''

Fill the password with your root password

$cfg['Servers'][$i]['password'] ='your_password'

And it Should Work. Happy hacking friends.

查看更多
叛逆
5楼-- · 2020-02-07 18:24

i'm trying this before

cd /opt/lampp/phpmyadmin

then

gedit config.inc.php

find this,

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

if there is localhost change it to 127.0.0.1

Note : if there is '//' remove // before $cfg['Servers'][$i]['host']

I checked again http://localhost/phpmyadmin/

mysqli said :

"phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server."

i'm opening again config.inc.php and i found

$cfg['Servers'][$i]['password'] =

Fill the password with your password

It worked for me. It may work for you too.

查看更多
Melony?
6楼-- · 2020-02-07 18:25

Maybe your SQL server has been stopped

sudo /etc/init.d/mysql start

or

sudo service mysqld start

and useservice mysql status to check status

查看更多
贼婆χ
7楼-- · 2020-02-07 18:28

First of all, make sure the mysql service is running:

ps elf|grep mysql

you will see an output like this if is running:

4 S root      9642     1  0  80   0 -  2859 do_wai 23:08 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/tomcat-machine.local.pid
4 S mysql     9716  9642  0  80   0 - 200986 poll_s 23:08 pts/0   00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/tomcat-machine.local.err --pid-file=/var/lib/mysql/tomcat-machine.local.pid

then change localhost to 127.0.0.1 in config.inc.php

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

The default password for "root" user is empty "" do not type anything for the password

If it does not allow empty password you need to edit config.inc.php again and change:

$cfg['Servers'][$i]['AllowNoPassword'] = true;

The problem is a combination of config settings and MySQL not running. This was what helped me to fix this error.

查看更多
登录 后发表回答