Ask Your Question
1

Weird issue with MariaDB and PHP

asked 2016-03-17 13:39:54 -0500

jfha73 gravatar image

updated 2016-03-21 15:18:59 -0500

Hey guys,

I have Fedora 23 on my machine, I installed MariaDB to it, compiled and installed PHP 7.0.4 to it, I created a script to test it and when I try to connect to loclahost, it gives me a connection error because of mysql.sock file not found, I configured both MySQL (PrivateTmp=False) and PHP (mysqli.default_socket) whith the path to the file, restarted both and still no connection to localhost. If I try to connect to 127.0.0.1 it does connect.

My Firewall is masked and SELinux disabled, my /etc/hosts has 127.0.0.1 as localhost, so it's not routing, the file exists and it has 777 permissions, so it's not permissions, at this point I ran out of ideas to check for, so any idea I'd appreciate it.

This is how I built it:

EXTENSION_DIR=/usr/lib64/php7/extensions ./configure --prefix=/usr --with-libdir=lib64 --with-apxs2=/usr/bin/apxs --with-config-file-path=/etc/php7/apache2 --with-config-file-scan-dir=/etc/php7/conf.d --with-openssl --with-kerberos --with-zlib=shared --enable-bcmath=shared --with-bz2=shared --enable-calendar --with-curl=shared --with-enchant=shared --enable-ftp --with-gd=shared --with-gettext=shared --with-mhash=shared --with-gmp=shared --with-imap=shared --with-imap-ssl --enable-intl=shared --with-ldap=shared --enable-mbstring=shared --with-mcrypt=shared --with-mysqli=shared --with-unixODBC=shared,/usr --with-pdo-mysql=shared --with-pdo-odbc=unixODBC,/usr --with-pdo-pgsql=shared --with-pgsql=shared --enable-shmop=shared --with-snmp=shared --enable-soap=shared --enable-sockets=shared --with-tidy=shared --enable-wddx=shared --with-xmlrpc=shared --with-xsl=shared --enable-zip=shared --enable-mysqlnd --with-pear

Can you tell me what I did wrong?

Just to recap, it connects to 127.0.0.1 (via TCP) but not to localhost (via socket), it sounds like a blockage, but again Firewall and SELinux are disabled/masked.

Thanks,

edit retag flag offensive close merge delete

Comments

If you compiled and installed and installed PHP, it is possible it is looking for a Mariadb socket on the wrong location for example regular mariadb install on my Fedora 23 machine has the mysql.sock file on /var/lib/mysql/ maybe your php is looking for in on other location like /var/run/ so you have two options change the location of the sock file on your ariadb or changit on php if possible.

aeperezt gravatar imageaeperezt ( 2016-03-17 14:12:00 -0500 )edit

Are you sure that localhost resolves to 127.0.0.1? Check in your /etc/nsswitch.conf the line starting with hosts. The first entry for that should be files. You can also check the name resolution directly in php with echo gethostbyname("localhost");

thomaswood gravatar imagethomaswood ( 2016-03-19 08:17:24 -0500 )edit

@thomaswood when "localhost" is used for mysql/mariadb connection is have the special meaning of "use the unix domain socket"

remi gravatar imageremi ( 2016-03-19 08:32:50 -0500 )edit

Alright, got it. Did you check what aeperezt mentioned and checked the path? The socket that is printed out when executing php -i | grep 'mysqli.default_socket', does that exist?

thomaswood gravatar imagethomaswood ( 2016-03-19 09:56:25 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2016-03-19 04:34:41 -0500

remi gravatar image

Instead of building from sources, try the existing RPM available in remi repository

RPM exists for single version (replacement of base packages) or parallel installation (Software Collections)

See the Configuration Wizard

Notice: these packages will be used for Fedora 25.

edit flag offensive delete link more

Comments

Of course, I have no issue to connect to local MariaDB server, so your build options are probably wrong.

remi gravatar imageremi ( 2016-03-19 04:35:26 -0500 )edit

Thank goodness you saw this Remi, I'll try now, can you check my configure line above and tell me what I did wrong?

Thanks

jfha73 gravatar imagejfha73 ( 2016-03-21 15:20:14 -0500 )edit

Again, why don't you simply use existing RPM ? (and too much things are wrong, starting by the prefix which should never be used for manually build software)

remi gravatar imageremi ( 2016-03-22 01:20:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-03-17 13:39:54 -0500

Seen: 205 times

Last updated: Mar 21 '16