How to make a remote MySQL server with socket by using SOCAT.
Remote MySQL advantages
– move MySQL CPU usage from local CWP web server
– move MySQL disk IO operations from disk
– move MySQL disk space usage to other server
– improve performances by moving MySQL to SSD multi-core powered server
on the remote MYSQL server
This needs to be a clean server, best would be a clean CentOS 6 minimal without any control panel.
Install MySQL server and Socat
yum install mysql-server socat -y
Run Socat listening for MySQL on the port 3307
socat TCP-LISTEN:3307,reuseaddr,fork UNIX-CONNECT:/var/lib/mysql/mysql.sock &
on the CWP Web server
1. Backup all databases
2. Import databases to the remote MySQL server
3. Update MySQL root password from MySQL server and add it in following files:
** Other option would be that you change MySQL root password on the MySQL server.
4. Stop local MySQL server
5. Add IP from CWP server to MySQL and from MySQL to CWP in firewall allow list.
Now lets create remote MySQL socket connection with socat (replace SERVER-IP)
socat UNIX-LISTEN:/var/lib/mysql/mysql.sock,fork,reuseaddr,unlink-early,user=mysql,group=mysql,mode=777 TCP:SERVER-IP:3307 &
If you have successful login in the cwp and local MySQL server is stopped than this means that you are connected on the remote MySQL server.
Disable local MySQL server or remove it.
For assistance you can contact our support