Bug #77531 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'
Submitted: 29 Jun 2015 7:41 Modified: 30 Jun 2015 6:40
Reporter: Shahriyar Rzayev (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Installing Severity:S1 (Critical)
Version:5.7.7-rc OS:CentOS (7)
Assigned to: CPU Architecture:Any

[29 Jun 2015 7:41] Shahriyar Rzayev
Description:
After initializing MySQL 5.7.7-rc to different datadir not default /var/lib/mysql:

[root@centos7_vm mysql]# bin/mysqld --initialize --user=mysql --datadir=/opt/mysql/datadir

I want to start MySQL:

[root@centos7_vm mysql]# bin/mysqld_safe --user=mysql &
[1] 2614
[root@centos7_vm mysql]# bin/mysqld_safe: line 542: /var/lib/mysql/mysqld_safe.pid: No such file or directory
awk: (FILENAME=- FNR=1) warning: error writing standard output (Broken pipe)
150629 12:02:57 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:02:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory
bin/mysqld_safe: line 164: /var/log/mariadb/mariadb.log: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:02:57 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory

[1]+  Done                    bin/mysqld_safe --user=mysql

As i remember, if we do not specify log-error path explicitly it should start from /var/log/mysqld.log.

But now it is looking for '/var/log/mariadb/mariadb.log'.

How to repeat:
# Install MySQL 5.7.7-rc from source using:

cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/opt/mysql/datadir -DSYSCONFDIR=/opt/mysql -DWITH_SSL=system -DMYSQL_TCP_PORT=3307 -DMYSQL_UNIX_ADDR=/opt/mysql/mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=1 -DCOMPILATION_COMMENT="Shahriyar Rzayev's MySQL" -DOPTIMIZER_TRACE=1 -DWITH_ZLIB=system  -DCMAKE_C_FLAGS=-DHAVE_purify -DCMAKE_CXX_FLAGS=-DHAVE_purify  -DWITH_BOOST=/opt/boost -DWITH_VALGRIND=1

make

make install

bin/mysqld --initialize --user=mysql --datadir=/opt/mysql/datadir

# Then try to start without specifying datadir you will hit error:

bin/mysqld_safe --user=mysql &

Suggested fix:
Fixing default log path to /var/log/mysqld.log as usual
[29 Jun 2015 7:47] Shahriyar Rzayev
Even with specifying --datadir it will fail:

[root@centos7_vm mysql]# bin/mysqld_safe --user=mysql --datadir=/opt/mysql/datadir
150629 12:46:08 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:46:08 mysqld_safe Starting mysqld daemon with databases from /opt/mysql/datadir
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory
bin/mysqld_safe: line 164: /var/log/mariadb/mariadb.log: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:46:08 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory
[29 Jun 2015 8:26] Shahriyar Rzayev
Some more tests:

# Running without any parameter:

[root@centos7_vm mysql]# bin/mysqld_safe
150629 12:57:43 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:57:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory
bin/mysqld_safe: line 164: /var/log/mariadb/mariadb.log: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:57:43 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory

# Running with unknown parameter:

[root@centos7_vm mysql]# bin/mysqld_safe kwelewr
150629 12:57:34 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:57:34 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory
bin/mysqld_safe: line 164: /var/log/mariadb/mariadb.log: No such file or directory
touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory
chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory
150629 12:57:34 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
bin/mysqld_safe: line 130: /var/log/mariadb/mariadb.log: No such file or directory
[29 Jun 2015 10:14] Shahriyar Rzayev
It seems that, there is a my.cnf file, even I have not installed any MariaDB.
So the problem exists because of abandoned my.cnf file which comes as default with CentOS 7.

Keeping in mind this,maybe documentation should be improved in some way, like note this problem in "installation from source section".
[30 Jun 2015 6:34] MySQL Verification Team
Hi Shahriyar,

Thank you for the report.
I would mark it as a not bug, because this was intended behavior. 
Normally, options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf and with my.cnf exists from earlier rpm installation caused this issue.

On my local build, I see something like below:

mysql-5.7.8: bin/mysqld --help --verbose 2> /dev/null | grep -B 1 '/etc/my.cnf'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

In such cases, you can always start with --no-defaults which can be used to prevent from unwanted option being read.

Thanks,
Umesh
[30 Jun 2015 6:40] Shahriyar Rzayev
Yes really it is not a bug.
There is a default my.cnf (MariaDB) with CentOS 7, even with fresh minimal installation.
We need just keep this in mind.