collected: change data dir of mysql results in errorcode 13
by setting up a mysql-db (on Scientific Linux 6.1 I run into trouble cause I’ve changed the data-dir to somewhat outside of /var/lib/mysql… and it won’t work, got errorcode 13 – permission denied. chowned, start – failed. checked permissions twice… but the net has the solution (spreaded over some pages) on some „modern“ linux systems SElinux secures anything. more or less usefull. simply setup the tables and change the SElinux security context of the new data dir to that of the former data dir. and (if needed/configured) don’t forget to create the inno-db-dir manually… sample for data-dir is /data/db/mysql with innoDB at /data/db/mysql/innodb:
#>mkdir -p /data/db/mysql/innodb
#>chown -R mysql.mysql /data/db/mysql
#>mysql_install_db --user=mysql --ldata=/data/db/mysql
#>chcon -R --reference=/var/lib/mysql /data/db/mysql
#>/etc/init.d/mysqld start
Addition: same fun for apache:
#>chcon -R -t httpd_user_content_t /data/www/html/