I'm trying to install mysql and mariadb on the same server as a parallel installation, each service on a different port.
I installed mysql server using apt-get on a debian-based distro and then mariadb following this tutorial using mariadb pre-compiled binaries.
At a first glance everything seems to work fine because:
A) I see both services listening on ports 3306 and 3307 after doing "netstat -latun":
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
B) From a remote host I can connect to both services via phpMyAdmin and via command line and execute queries:
MySQL:
mysql -u root -pmypassword -h x.x.x.x --port 3306
MariaDB:
mysql -u root -pmypassword -h x.x.x.x --port 3307
C) On the server I can successfully connect to both consoles and execute queries using:
MySQL:
mysql -u root -pmypassword --port 3306
MariaDB:
mysql -u root -pmypassword --socket=/opt/mariadb-data/mariadb.sock
What's not working
Cannot connect like this:
/opt/mariadb/bin/mysql -u root -pmypassword --port 3307
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")
Connects to port 3306 instead:
/usr/bin/mysql -u root -pmypassword --port 3307
I believe that as a consequence of the previous errors my Joomla installation works only when mysql is up running either on port 3306 or 3307.
When only MariaDB is up running on either port Joomla displays:
Database connection error (2): Could not connect to MySQL.Database connection error (2): Could not connect to MySQL.
and command line:
# /usr/bin/mysql -u root -pmypassword
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
# /opt/mariadb/bin/mysql -u root -pmypassword
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")
When MariaDB is running I still can connect via phpMyAdmin and command line from a remote host or via command line on the server using the --socket option.
I have to notice though that during previous tests, starting from a mysql installation I installed mariadb-server via apt-get and it replaced the mysql installation and everything worked fine either via command line or via any php cms framework for that matter.
I think there are still references to mysql somewhere, to its socket file in particular because using --socket option through command line makes it work everytime
At this point I believe apache and php come into the picture but don't know yet where to dig.
Bottom line:
- From a remote host phpMyAdmin and command line work with every service on either port.
- On the server Apache and php do not connect to MariaDB on either port
- Connect to MariaDB via command line on the server only works if --socket option is given.
While I research on this matter, is there any suggestion?
Thank you very much.