Configure MySQL

From Scottworld
Jump to navigation Jump to search

If you want to allow access to your MYSQL database from any other host rather than the LOCAL server you will have to tell MySQL to bind to the external ip address rather than the local TCP stack... (which is the default)

service mysql stop
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Modify the line

bind-address = (change to the externally bound IP address)

Move the default database directory off the system disk

datadir = /srv/data/mysql

Move the existing database folder to new location

mv /var/lib/mysql /srv/data/mysql

Now we need to modify apparmor to allow access to this new directory.

nano /etc/apparmor.d/local/usr.sbin.mysqld
# Site-specific additions and overrides for usr.sbin.mysqld.
# For more details, please see /etc/apparmor.d/local/README.

/srv/data/mysql/ r,
/srv/data/mysql/** rwk,

# Added to fix mem DENIED - for MySQL -  check with dmesg | less

capability dac_read_search,
@{PROC}/@{pid}/status r,
/sys/devices/system/node/ r,
/sys/devices/system/node/node[0-9]*/meminfo r,

Now restart the apparmor service

service apparmor reload

Make a symlink to the new locacation (the startup script is broken startup script is broken)

ln -s /srv/data/mysql /var/lib/mysql ---- NOT NEEDED

Restart MySQL service

service mysql restart