mysql - 16.04, can't mysqld --initialize in non-default location - Ask Ubuntu


i running mysqld on 14.04 non-standard --datadir (/usr/local/mysqld-test) & port (33306). after upgrading 16.04, no longer able start test mysqld, so, following instructions here , in bug links here, wound going far as:

sudo apt purge mariadb-client-10.0 mariadb-common mysql-client mysql-client-5.7 mysql-client-core-5.7 mysql-common dbconfig-mysql sudo apt-get install mysql-client mysql-server 

(in process, uninstalled amarok!? snarl)

that still wasn't working, wound nuking entire /usr/local/mysqld-test (intentionally; in theory have scripts rebuild it). mysql_install_db command had used before deprecated now, , doesn't seem understand -p 33306 argument, instead i'm trying use mysqld --initialize-insecure.

here's i'm doing:

mysqld --initialize-insecure --basedir=/usr/local/mysqld-test --datadir=/usr/local/mysqld-test/data 

it fails:

mysqld: can't create directory '/usr/local/mysqld-test/data/' (errcode: 13 - permission denied) 2016-11-02t10:21:37.547443z 0 [warning] timestamp implicit default value deprecated. please use --explicit_defaults_for_timestamp server option (see documentation more details). 2016-11-02t10:21:37.549183z 0 [error] aborting 

huh. thought made world-writable:

$ ls -al /usr/local/mysqld-test total 8 drwxrwxrwx  2 kuhrusty kuhrusty 4096 nov  2 03:13 . drwxr-xr-x 20 root     root     4096 nov  2 03:13 .. 

wtf? let's try strace:

execve("/usr/sbin/mysqld", ["mysqld", "--initialize-insecure", "--basedir=/usr/local/mysqld-test", "--datadir=/usr/local/mysqld-test"...], [/* 69 vars */]) = 0 ... 

it mmaps bunch of shared libraries, sets signal handlers, , looks config files (which don't think i've messed with--i start manually, passing --datadir, -p, etc.):

stat("/etc/my.cnf", 0x7ffe13e99af0)     = -1 enoent (no such file or directory) stat("/etc/mysql/my.cnf", {st_mode=s_ifreg|0644, st_size=682, ...}) = 0 open("/etc/mysql/my.cnf", o_rdonly)     = 3 fstat(3, {st_mode=s_ifreg|0644, st_size=682, ...}) = 0 read(3, "#\n# mysql database server co"..., 4096) = 682 open("/etc/mysql/conf.d/", o_rdonly|o_nonblock|o_directory|o_cloexec) = 4 fstat(4, {st_mode=s_ifdir|0755, st_size=4096, ...}) = 0 brk(0x271d000)                          = 0x271d000 getdents(4, /* 4 entries */, 32768)     = 120 getdents(4, /* 0 entries */, 32768)     = 0 close(4)                                = 0 stat("/etc/mysql/conf.d/mysql.cnf", {st_mode=s_ifreg|0644, st_size=8, ...}) = 0 open("/etc/mysql/conf.d/mysql.cnf", o_rdonly) = 4 fstat(4, {st_mode=s_ifreg|0644, st_size=8, ...}) = 0 read(4, "[mysql]\n", 4096)              = 8 read(4, "", 4096)                       = 0 close(4)                                = 0 stat("/etc/mysql/conf.d/mysqldump.cnf", {st_mode=s_ifreg|0644, st_size=55, ...}) = 0 open("/etc/mysql/conf.d/mysqldump.cnf", o_rdonly) = 4 fstat(4, {st_mode=s_ifreg|0644, st_size=55, ...}) = 0 read(4, "[mysqldump]\nquick\nquote-names\nma"..., 4096) = 55 read(4, "", 4096)                       = 0 close(4)                                = 0 brk(0x2713000)                          = 0x2713000 brk(0x270a000)                          = 0x270a000 open("/etc/mysql/mysql.conf.d/", o_rdonly|o_nonblock|o_directory|o_cloexec) = 4 fstat(4, {st_mode=s_ifdir|0755, st_size=4096, ...}) = 0 getdents(4, /* 4 entries */, 32768)     = 128 getdents(4, /* 0 entries */, 32768)     = 0 close(4)                                = 0 stat("/etc/mysql/mysql.conf.d/mysqld.cnf", {st_mode=s_ifreg|0644, st_size=3028, ...}) = 0 open("/etc/mysql/mysql.conf.d/mysqld.cnf", o_rdonly) = 4 fstat(4, {st_mode=s_ifreg|0644, st_size=3028, ...}) = 0 read(4, "#\n# mysql database server co"..., 4096) = 3028 read(4, "", 4096)                       = 0 close(4)                                = 0 stat("/etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf", {st_mode=s_ifreg|0644, st_size=21, ...}) = 0 open("/etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf", o_rdonly) = 4 fstat(4, {st_mode=s_ifreg|0644, st_size=21, ...}) = 0 read(4, "[mysqld_safe]\nsyslog\n", 4096) = 21 read(4, "", 4096)                       = 0 close(4)                                = 0 read(3, "", 4096)                       = 0 close(3)                                = 0 stat("/home/kuhrusty/.my.cnf", 0x7ffe13e99af0) = -1 enoent (no such file or directory) stat("/home/kuhrusty/.mylogin.cnf", 0x7ffe13e99af0) = -1 enoent (no such file or directory) getrlimit(rlimit_nofile, {rlim_cur=1024, rlim_max=64*1024}) = 0 setrlimit(rlimit_nofile, {rlim_cur=5000, rlim_max=5000}) = 0 getrlimit(rlimit_nofile, {rlim_cur=5000, rlim_max=5000}) = 0 umask(026)                              = 02 open("/etc/localtime", o_rdonly|o_cloexec) = 3 fstat(3, {st_mode=s_ifreg|0644, st_size=2845, ...}) = 0 fstat(3, {st_mode=s_ifreg|0644, st_size=2845, ...}) = 0 read(3, "tzif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\0\5\0\0\0\0"..., 4096) = 2845 lseek(3, -1811, seek_cur)               = 1034 read(3, "tzif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0\0\0\5\0\0\0\0"..., 4096) = 1811 close(3)                                = 0 uname({sysname="linux", nodename="tentacle", ...}) = 0 brk(0x2732000)                          = 0x2732000 brk(0x2724000)                          = 0x2724000 lstat("/usr", {st_mode=s_ifdir|0755, st_size=4096, ...}) = 0 lstat("/usr/local", {st_mode=s_ifdir|0755, st_size=4096, ...}) = 0 lstat("/usr/local/mysqld-test", {st_mode=s_ifdir|0777, st_size=4096, ...}) = 0 lstat("/usr", {st_mode=s_ifdir|0755, st_size=4096, ...}) = 0 lstat("/usr/local", {st_mode=s_ifdir|0755, st_size=4096, ...}) = 0 lstat("/usr/local/mysqld-test", {st_mode=s_ifdir|0777, st_size=4096, ...}) = 0 lstat("/usr/local/mysqld-test/data", 0x7ffe13e9d1d0) = -1 enoent (no such file or directory) open("/usr/share/mysql/english/errmsg.sys", o_rdonly) = 3 read(3, "\376\376\3\1\1\0\335\26\1\0008\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0", 32) = 32 read(3, "\0\0\0\0\10\0\0\0\20\0\0\0\23\0\0\0\27\0\0\0d\0\0\0m\0\0\0\231\0\0\0"..., 4320) = 4320 read(3, "hashchk\0isamchk\0no\0yes\0can't cre"..., 71389) = 71389 close(3)                                = 0 stat("/usr/local/mysqld-test/share/mysql/charsets/index.xml", 0x7ffe13e9e2e0) = -1 enoent (no such file or directory) futex(0x1ddcf48, futex_wake_private, 2147483647) = 0 brk(0x2745000)                          = 0x2745000 open("/usr/local/mysqld-test/data/", o_rdonly|o_nonblock|o_directory|o_cloexec) = -1 enoent (no such file or directory) mkdir("/usr/local/mysqld-test/data/", 0750) = -1 eacces (permission denied) 

ok, now, think that's things go wrong (note: make sure scroll bottom)... why? anyone can create file there!

write(2, "mysqld: ", 8)                 = 8 write(2, "can't create directory '/usr/loc"..., 87) = 87 write(2, "\n", 1)                       = 1 mysqld: can't create directory '/usr/local/mysqld-test/data/' (errcode: 13 - permission denied) 

wtf?? problem, 14.04 -> 16.04 upgrade ranks third biggest mistake of life... feel i've suffered 1 of traumatic brain injuries forget how read. permissions right, right?? running mysqld --initialize under sudo doesn't make difference. there incredibly stupid thing i'm doing wrong?

arghh apparmor hosed me. second answer here gave me hint needed in log:

[137519.814104] audit: type=1400 audit(1478218238.219:177): apparmor="denied" operation="mkdir" profile="/usr/sbin/mysqld" name="/usr/local/mysqld-test/data/" pid=7126 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000 

following these instructions, disabled apparmor mysql:

sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld cd /etc/apparmor.d/disable sudo ln -s /etc/apparmor.d/usr.sbin.mysqld . 

and confirmed mysqld no longer in enforce mode:

sudo aa-status 

and mysqld --initialize-insecure started & ran way expected work 2 days ago.

(how/why did apparmor installed/enabled during 14.04 -> 16.04 upgrade? don't think i'd heard of apparmor before this; "your stuff no longer going work way used to" seems kind of information should've been given during upgrade!)


Comments

Popular posts from this blog

Windows XP installation, no previous version of Windows NT - Super User

permissions - Mount is denied because the NTFS volume is already exclusively opened - Ask Ubuntu

software installation - How to install linux driver for a lb-link wireless usb adapter - Ask Ubuntu