First I created a dir to hold my database data
mkdir /var/www/db_test
Then used symbolic links
ln -s /var/www/db_test/ /var/lib/mysql/
When I entered /var/lib/mysql/, I saw db_test dir with shortcut icon with all my exist databases. But I cannot connect to db_test in php script, even when I tried to chmod and restart apache and mysql server.
/var/log/syslogfor audits from AppArmor, that sounds like something it would forbid – charlesbridge May 24 '12 at 11:27May 25 13:51:15 ubuntu kernel: [ 318.039386] type=1400 audit(1337928675.784:34): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/var/www/db_test/db.opt" pid=995 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=114 ouid=114 May 25 13:51:15 ubuntu kernel: [ 318.039529] type=1400 audit(1337928675.784:35): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/var/www/db_test/" pid=995 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=114 ouid=114– duy May 25 '12 at 7:36sudo aa-complain /usr/sbin/mysqldto have it log audits but not enforce them (help.ubuntu.com/community/AppArmor) – charlesbridge May 25 '12 at 11:11