Originally Posted by linutzy
I essentially just want my apache machine (box1) to connect to my mysql machine (box2) . So every time my site is accessed from box1, which will be public facing, if a database is used on the site (Wordpress), box2 handles it. I essentially need both machines to communicate with each other.
it is more a matter of configuring the MySQL box to accept network connections, then configuring the WordPress (or other) DB to use that machine for access.
The examples I give here are for Slackware but will be very similar for other distros...
First, on the MySQL machine, make sure the server is not
started with --skip-networking
option. This may either be added in the MySQL start script, like /etc/rc.d/rc.mysqld, OR it might be found in /etc/my.cnf. If it is found, comment it out and restart the MySQL server, however that is done on your machine (/etc/rc.d/rc.mysqld restart for Slackware).
Next, you will need to grant access rights to a user from the Apache machine. From the shell as root (or MySQL admin user)
mysql -pxxxxxxxx (start the mysql client)
GRANT ALL ON DB.* TO apache-user@apache-host IDENTIFIED BY 'XXXXXXXX';
Where xxxxxxxx and XXXXXXXX are the respective user passwords, DB is the database name.
'apache-user' is the name used from the Apache machine (not necessarily a username on that machine) and apache-host is the host name or IP address of the Apache machine.
Finally, on the Apache machine in the WordPress or other config, set the equivalent of:
That should do it.
Your distro may provide different ways of restarting the mysqld daemon, and the hosts of course must be visible to each other on the network wither by name or address, but these are the basic requirements.