How to change phpMyAdmin to utilise a domain socket when conecting to MariaDB on the IBM i
We use phpMyAdmin to do some important database adminstration on our MySQL databases. phpMyAdmin comes as a free piece of software developed using PHP. The software allows us to directly edit databases, maintain table definitions, run SQL statements, backup databases, monitor tables and much more. We have recently upgraded our MariaDB database and version of PHP. Doing this allowed us to change the method by which we connect to the database. Previously we used a TCP connection on port 3306 but now we have implemented a domain socket connection. This has two major advantages which are improved performance and better security.
The domain socket is very easy to implement with phpMyAdmin. Although we use the Community version of PHP supplied by the Seiden Group and deployed through Access Client Solutions we still run phpMyAdmin through the ZENDPHP7 subsystem just because it works and it was there from our old Zend version of PHP and ZendDBi, if aint broke don’t fix it!
So in order to change the way the phpMyAdmin accesses MariaDB in the Zend version (This will also work for implentations outside of Zend just different PHP connection details file) we need to locate the PHP file that holds the connection details. On our IBM i this is stored in a file with a fully qualified path name of /usr/local/zendphp7/var/apps/http/__default__/0/active/config.inc.php
In order to change from a TCP database connection to a domain socket connection we need to comment out the lines that references the host and port number asmper the examples below:
// $cfg['Servers'][$i]['host'] = '127.0.0.1'; // $cfg['Servers'][$i]['port'] = '3306';
And then replace them with the details that will enable the domain socket connection to MariaDB.
$cfg['Servers'][$i]['socket'] = '/QOpenSys/var/lib/mysql/mysql.sock'