Home > database >  [for] under Ubantu18.04, modified Mysql5.7 data file storage path, Mysql startup fails,
[for] under Ubantu18.04, modified Mysql5.7 data file storage path, Mysql startup fails,

Time:04-26

The original data file storage directory is the default/var/lib/mysql
The new data file storage directory is/mysql/mysqldata/mysql

1, modify the/etc/mysql/mysql. Conf. D/mysqld. CNF, as follows:
# datadir=/var/lib/mysql
Datadir=/mysql/mysqldata/mysql

2, modify the/etc/apparmor. D/usr. Sbin. Mysqld, as follows:

# Allow data dir access
#/var/lib/mysql/r,
#/var/lib/mysql/* * RWK,
/mysql/mysqldata/mysql/r,
/mysql/mysqldata/mysql/* * RWK,

3, modify the/usr/share/mysql/mysql - systemd - start, as follows:

Datadir=$(get_mysql_option mysqld datadir "/mysql/mysqldata/mysql")

Perform the
Sudo service apparmor reload
Sudo service apparmor restart
Sudo service mysql start

Mysql or start an error, sensory systems also before reading the Mysql data directory, log specific as follows, what a great god look out where is the problem? Thank you very much ~ ~ ~
======================================================================
Apr 25 15:39:45 systemd ecs - 0002 [1] : Starting MySQL Community Server...
Apr 25 15:39:45 ecs - 0002 kernel: [337743.034195] kauditd_printk_skb: 7 callbacks suppressed
Apr 25 15:39:45 ecs - 0002 kernel: [337743.034196] audit: audit type=1400 (754) : 1619336385.730: apparmor="DENIED" operation="mknod profile=" "/usr/sbin/mysqld" name="/var/lib/mysql/ecs - 0002. The lower - test" pid=21013 comm="mysqld requested_mask=" c "denied_mask=" "c" fsuid=0 ouid=0
Apr 25 15:39:45 ecs - 0002 kernel: [337743.035880] audit: audit type=1400 (755) : 1619336385.734: apparmor="DENIED" operation="mknod profile=" "/usr/sbin/mysqld" name="/var/lib/mysql/ecs - 0002. The lower - test" pid=21013 comm="mysqld requested_mask=" c "denied_mask=" "c" fsuid=0 ouid=0
Apr 25 15:39:45 ecs - 0002 kernel: [337743.035884] audit: audit type=1400 (756) : 1619336385.734: apparmor="DENIED" operation="mknod profile=" "/usr/sbin/mysqld" name="/var/lib/mysql/ecs - 0002. The lower - test" pid=21013 comm="mysqld requested_mask=" c "denied_mask=" "c" fsuid=0 ouid=0
Apr 25 15:39:45 ecs - 0002 kernel: [337743.235041] audit: audit type=1400 (757) : 1619336385.930: apparmor="DENIED" operation="mknod profile=" "/usr/sbin/mysqld" name="/var/lib/mysql/ecs - 0002. The lower - test" pid=21018 comm="mysqld requested_mask=" c "denied_mask=" "c" fsuid=113 ouid=113
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 936809 z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Do use - explicit_defaults_for_timestamp server option (see documentation for more details).
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 936972 z 0 [Warning] Can 't create the test file/var/lib/mysql/ecs - 0002. The lower - test
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 937003 z 0 [Note]/usr/sbin/mysqld (mysqld 5.7.33-0 ubuntu0. 18.04.1) starting as the process of 21018...
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 939389 z 0 [Warning] Can 't create the test file/var/lib/mysql/ecs - 0002. The lower - test
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 939405 z 0 [Warning] Can 't create the test file/var/lib/mysql/ecs - 0002. The lower - test
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 940927 z 0 [Note] InnoDB: PUNCH HOLE support available
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. [Note] InnoDB: 0 940992 z Mutexes and rw_locks use GCC atomic builtins
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 940999 z 0 [Note] InnoDB: Uses the event mutexes
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 941001 z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence () is 2 for the memory barrier
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 941003 z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 941006 z 0 [Note] InnoDB: Using Linux native AIO
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 941210 z 0 [Note] InnoDB: Number of pools: 1
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 941305 z 0 [Note] InnoDB: Using CPU crc32 instructions
Apr 25 15:39:45 ecs - 0002 kernel: [337743.237442] audit: audit type=1400 (758) : 1619336385.934: apparmor="DENIED" operation="mknod profile=" "/usr/sbin/mysqld" name="/var/lib/mysql/ecs - 0002. The lower - test" pid=21018 comm="mysqld requested_mask=" c "denied_mask=" "c" fsuid=113 ouid=113
Apr 25 15:39:45 ecs - 0002 kernel: [337743.237445] audit: audit type=1400 (759) : 1619336385.934: apparmor="DENIED" operation="mknod profile=" "/usr/sbin/mysqld" name="/var/lib/mysql/ecs - 0002. The lower - test" pid=21018 comm="mysqld requested_mask=" c "denied_mask=" "c" fsuid=113 ouid=113
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 942740 z 0 [Note] InnoDB: Initializing buffer pool, the total size=128 m, the instances=1, the chunk size=128 m
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. 949767 z 0 [Note] InnoDB: Completed initialization of buffer pool
Apr 25 15:39:45 mysqld ecs - 0002 [21016] : the 2021-04-25 T07:39:45. [Note] InnoDB: 951759 z 0 If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority ().
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull