I am trying to install phpMyAdmin on a machine running ubuntu, for reasons of compatibility I have am running a backdated binary version of MySQL (5.5.54). It is essentially running okay, I can access databases from php clients using localhost.
When I try to use the auto configure script included with phpMyAdmin, I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket d '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
Effectively there is no folder at the location /var/run/mysqld. In file 'my.cnf' the socket is set as socket = /tmp/mysql.sock I have not yet found how to alter this default, it would seem that this is a possible mismatch, there is also a second file, added on installing phpMyAdmin called my.cnf.server.
Should I look to change the socket, or, perhaps configure phpMyAdmin manually?
I would appreciate some help.
This post seems related:
Help to change mysql.sock
Though I was wondering if it is possible to change the socket that phpMyAdmin is looking for. Was the default changed in later versions of mysql; Currently running 5.5.54 for compatibility reasons.
configure PMA to use the correct socket. in config.inc.php replace
$cfg['Servers'][$i]['host'] = 'localhost';
with
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
I was able to get around this by switching phpMyAdmin from socket connection to TCP connection:
vi /etc/phpmyadmin/config.inc.php and enter the IPAddress instead of localhost
I also had to change the dbserver and dbport in vi /etc/phpmyadmin/config-db.php
I found out that PHP and PhpMyAdmin actually do get their socket values from /etc/my.cnf just that you need to do a service php-fpm restart before mysqli.default_socket is reflected in phpinfo() and phpmyadmin.
in /etc/my.cnf
Careful about the datadir value, in my example I specified these to completely move MySQL directory.
[mysqld]
datadir=/SSD-2/mysql
socket=/SSD-2/mysql/mysql.sock
mysqlx_socket=/SSD-2/mysql/mysqlx.sock
Then important:
service php-fpm restart
So in this case, it was no need to edit /etc/php.ini and /etc/phpMyAdmin/config.inc.php anymore .
Related
I just updated my mac to 10.13 and reinstalled my dev tools. While setting up phpmyadmin it was unable to connect to mysql using:
$cfg['Servers'][$i]['host'] = 'localhost';
phpmyadmin throws:
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.
instead I had to use to get it working:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
In the past I could leave the default "localhost" and had no issues but it won't connect via socket any more.
My mysql user is 'root'#'localhost', using latest mysql, apache, phpmyadmin.
What could be the reason?
Thanks
Thanks to #N00b Pr0grammer's suggestion, I went trough the different solution still I figured it out.
On fresh installs of OS X, php.ini is turned off, and by default looks for mysqli.default_socket at "/var/mysql/mysql.sock" so I had to 1. rename php.ini.default to php.ini than 2. set:
mysqli.default_socket = /tmp/mysql.sock
and restart apache. Now phpmyadmin is able to connect to mysql via localhost as well.
There can be more than one reason for this to happen and the same has been discussed on this question as well. I suggest that you go through the answers provided on this question to resolve the error based on your environment that you hold.
This is the ServerFault question!
The common problem that I tend to see in dev environments is this:
You may have IPv6 enabled, its very possible localhost resolves to the IPv6 localhost, that is not defined in your MySQL config.
I'm trying to connect on my mysql database when I'm not on localhost - on localhost it's working. Everytime I wish to connect, I don't have any error, but only a timeout exec...
Here is what I've done so far
create a user on mysql who can access to any hosts("%")
purge the iptables
my port 3306 is opened (see screenshot)
the bind-address line is 0.0.0.0 in the mysqld.cnf file - I even tried to put in it comment - please note my.cnf sends to the mysqld.cnf file.
of course for every modification I've restarted the mysql server - and the server itself...
no firewall are setup...
I'm on Ubuntu 16.04 LTS, mysql and phpmyadmin are setup on it.
What I'm missing ?
Thank you for your help
Bastien
After you changed the bind address you restarted with systemctl restart mysql.service, yes?
Here's a very similar situation, try following all of these steps: Remote Connections Mysql Ubuntu
I think the flush privileges step will be a help to you.
It is impossible to connect to mysql that I setup with phpmyadmin on a debian 8 VPS. I have been searching for hours, I have even followed this guide http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html but nothing, it seems imposible to get to connect to it, I even have created a phpmyadmin profile that is not on localhost and on %...
Thanks a lot for helping...
111 means connection refused, so make sure your mysql config is correct, and check your firewall.
Mysql config details (from Can't connect to MySQL server error 111):
If you have lines like this :
skip-networking
bind-address = 127.0.0.1
In your my.cnf configuration file, you should comment them (add a # at the beginning of the lines), and restart MySQL.
That's the first thing to try. Then try turning off any firewall and connecting again. That will tell you whether there's a firewall problem.
OS: Ubuntu 14.04 LTS
php version control : phpbrew
php version : 5.5.10
I pinged localhost which resolved to 127.0.0.1.
This indicates that my host (/etc/hosts) file is correct.
127.0.0.1 localhost
Whenever I try connecting to MySQL using a php script like the one below it doesn't work and gives me the error: no such directory.
//connect to the database
mysql_connect("localhost","root","password") or die(mysql_error());
However, when I connect via 127.0.0.1 it will work
//connect to the database
mysql_connect("127.0.0.1","root","password") or die(mysql_error());
Additionally, my phpmyadmin does not work when logging in using "localhost" i had to change the file to add 127.0.0.1 option during log on.
How can I use localhost to connect to the MySQL database?
PHP is still trying to use the default socket location. This problem can appear if you have moved the MariaDB/MySQL folder from /var/lib/mysql to another location. In order to solve the problem you have to define the new socket's location in the /etc/php.ini file.
mysqli.default_socket =/newDBLocation/mysql/mysql.sock
Watch out, depending on which driver you use, you may have to specify the pdo_mysql.default_socket=!
In order to check your current directory run the following command in mysql:
select ##datadir;
In many cases localhost is a hint to use the UNIX socket to connect to the MySQL server process, where 127.0.0.1 forces a TCP connection. Sometimes the UNIX socket is in an unexpected place, or simply isn't accessible, which results in the "file not found" error.
The socket is typically something like /tmp/mysql.sock or could be in some other place depending on your distribution and how much you've customized it.
Keep in mind that access via UNIX socket, which is local to the server by definition, and TCP are controlled by two different rules. localhost in a GRANT refers to UNIX socket. % or some specific host name refers to remote via TCP.
The answer to this problem was that in the my.cnf located within
/etc/mysql/my.cnf
the line was either
bind-address = 127.0.0.1
or
bind-address = localhost
it should have been
bind-address = 0.0.0.0
which will allow all connections
I've been attempting pretty much all day to get Symfony2's Doctrine configuration screen (e.g. /app_dev.php/_configurator/step/0) to connect to my locally running MAMP-provided MySQL instance. I've spent the day reading about sockets, skip-networking, and every other possible scenario but I'm at a loss. This is the error that you have most certainly seen before:
An exception occured in driver: SQLSTATE[HY000] [2003] Can't connect to MySQL
server on '127.0.0.1' (61)
And here are the various ways I have tried to correct this maddening problem:
I verified that I can indeed connect on the command line to both localhost and 127.0.0.1 using the mysql command. I made sure the ports were both filled in and not so I could see the results of an actual error.
I checked the socket while I was in there via SHOW variables LIKE 'socket' and saw it pointed correctly to my MAMP socket.
I've oscillated between the MAMP default ports and the standard MySQL ports (3306) just in case it was a weird port thing.
I made sure my /var/mysql and /tmp/mysql mysql.sock files were correctly symlinked to MAMP.
I commented out the skip-networking lines in MAMP's configuration file.
I toggled the "Allow Network Access" in every configuration possible
I added the line, unix_socket: /Applications/MAMP/tmp/mysql/mysql.sock, to my config.yml file just in case my symlinking trickery failed me.
I've done several rain dances and other tribal spells I read in a magazine trying to get this to connect.
I'm no stranger to development and MySQL but this has become a lost cause. Any help would be appreciated and rewarded with my unflinching respect for you.
The error code 2003 means "Can't connect to MySQL server", you can try to use the following methods.
Check your config file, is the parameters.yml can be access ? If you are on linux, just sudo chmod 777 /path/to/parameters.yml, and the mysql connection config parameters looks like this:
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1 or localhost
database_port: null
database_name: yourdbname
database_user: youraccount
database_password: yourpassword
Try to use localhost instead of 127.0.0.1;