Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Thanks. I followed the steps bit I had to add one more step ie, create symlink
**ln -s /data/mysql /var/lib/mysql **
or
keep the socket location as such ie /var/lib/msql/mysql.sock
This comment has been deleted
Dont forget many installations will need the SELinux context changed on the new files.
sudo chcon -R system_u:object_r:mysqld_db_t:s0 /mnt/volume-nyc1-01/mysql
Also, it may be necesary to update the socket direction in the php configuration. To do so:
Open the php.ini with sudo vi /etc/php.ini and find this line:
mysql.default_socket
And make it:
mysql.default_socket = /path/to/mysql.sock
If you are using PDO, there is a similar line to change. After that do:
sudo systemctl reload php-fpm sudo systemctl reload httpd
Everything should work after that.
I had a friend who was trying to move the dir into the /home/mysql (i don’t know why) but he found that there’s a setting that prevent’s the user read from there.
I’ll paste the solution here in case that someone else is looking for it:
The problem is the systemd service file mariadb.service which has set
ProtectHome = true
This setting prevents the service from accessing /home, /root and /run/user directories.
So either you mount your mysql data to a different location or you set this feature to false.
To disable this feature, best would be to use systemctl edit mariadb which opens the editor defined in the environment variable EDITOR. Just put:
[Service]
ProtectHome = false
Save and close and an override file /etc/systemd/system/mariadb.service.d/override.conf will be created. After that a systemctl daemon-reload is needed to re-read the setting. Start your service.
What is the rationale for changing the socket path? You do not explain this at all. Please do so. More over the file locations vary greatly, in my installation on debian 12, the datadir is radically different which was no surprise… but the socket path was also in a completely different configuration file. You example implies it is always in the same file as the datadir… in my case that was not the case.