4

Edit: My question is different than existing questions because I need a way without installing mysql to local server. Please do not throw blindly duplicate question tags to questions. Thanks.


Edit 2: Indeed this is not a duplicate, unlike some people still blindly insisted. I am able to connect to remote server without having mysql-client and server packages on the server and successfully executed queries through phpmyadmin interface after adding a custom line into codebase. I have created an issue on phpmyadmin github repository for this problem and also added my solution. I'm going to share my solution in here if this duplicate tag removed.


Question:

I'm trying to connect a remote mysql server and I've manually downloaded phpmyadmin and unzipped into a custom /phpmyadmin folder. I've configured my custom config.inc.php.

I don't have custom mysql installation and this is not a preferred option.

Same settings are working for my php-mysql application but it does not work for phpmyadmin and I'm getting this error when trying to login to phpmyadmin:

#2002 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) — The server is not responding (or the local server's socket is not correctly configured).

enter image description here

/*
 * Generated configuration file
 * Generated by: phpMyAdmin 4.7.9 setup script
 * Date: Wed, 07 Mar 2018 08:09:19 +0000
 */

/* Servers configuration */
$i = 0;

/* Server: dev-staging [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'dev-staging';
$cfg['Servers'][$i]['host'] = 'external_ip';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = true;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'dev_wp_user';
$cfg['Servers'][$i]['password'] = 'dev_password';

/* End of servers configuration */
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['blowfish_secret'] = 'z{<F1!k=CjIVTpg)^wJq;StO?sL{F-^E';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
$cfg['connect_type'] = 'tcp';
Community
  • 1
  • 1
mirza
  • 5,685
  • 10
  • 43
  • 73
  • 1
    Possible duplicate of [error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'](https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq) – Aniket Sahrawat Mar 07 '18 at 09:56
  • this might help. https://www.digitalocean.com/community/questions/mysql-can-t-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2 – Zaheer Abbas Mar 07 '18 at 09:56
  • 1
    Did you even read the question ? It's not same. @AniketSahrawat – mirza Mar 07 '18 at 10:00
  • 1
    @motto Did you even read the solution? It's same. No arguments – Aniket Sahrawat Mar 07 '18 at 10:00
  • Yes I read it unlike you. I don't have local mysql installation and it's not a preferred option genius. @AniketSahrawat I read all 32 answers from the previous question before opening this one. – mirza Mar 07 '18 at 10:03
  • If you are under proxy network, you might not connect to external ip – ManiMuthuPandi Mar 07 '18 at 10:03
  • @ManiMuthuPandi it works for wp installation on the server with same settings. So, I have access to external server. – mirza Mar 07 '18 at 10:05

2 Answers2

1

It looks like that phpMyAdmin cannot use your config.inc.php and is trying to use default localhost connection instead. This could be caused by missing php open tag in the beginning of the file. phpMyAdmin suppress output and errors during config file processing, so it maybe complicated to notice if something is wrong with it.

voter
  • 348
  • 1
  • 2
  • 8
  • 1
    Thanks for the answer, although it's not a direct solution for my problem helped me to realize what was the issue. Please check https://github.com/phpmyadmin/phpmyadmin/issues/14065 – mirza Mar 07 '18 at 22:27
  • 1
    @motto I looked at the code, your modification of getConnectionParams may be necessary because phpMyAdmin cannot load config file normally. I would check config file location. In my case it is located in the root of installation directory, but in your opened issue you wrote about config/config.inc.php. Maybe location of config is incorrect. Also it may be affected by CONFIG_DIR in vendor_config.php. It is empty ('') in my case. I am using 4.7.9 on CentOs. But anyway, good that you found solution that is working in your case :) – voter Mar 07 '18 at 22:55
  • I tried both of those locations. root and inside config folder. It didn't made any difference. – mirza Mar 07 '18 at 23:00
1

I was facing the same issue and find a correct solution.

  1. Open installation folder.
  2. you will see "config.sample.inc.php"
  3. rename it "config.inc.php" and then open
  4. change the $cfg['Servers'][$i]['host'] value with your server address. In my case, its 192.168.1.102 (i am using nodejs with mysql)
  5. And then restart xampp,wampp (Apache) or any other php server.
  6. Open http://localhost/phpMyAdmin/index.php enter image description here
Sudhir K Gupta
  • 65
  • 1
  • 11