nikosd nikosd - 1 year ago 107
Linux Question

MySQL installation from deb, permissions issues

I am trying to install MySQL on ubuntu 14.04 from the deb packages. I am having trouble starting the mysql server, it looks like a permissions problem. I followed the steps outlined here. Downloaded/untarred/installed deb tar bundle.

sudo apt-get install libaio1
tar -xvf mysql-server_5.7.4-m14-2ubuntu14.04_amd64.deb-bundle.tar
md5sum mysql-server_5.7.4-m14-2ubuntu14.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-server_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient18_5.7.4-m14-2ubuntu14.04_amd64.deb

Here is where the files are installed on my system:
All configuration files (like
) are under
All binaries, libraries, headers, etc., are under
The data directory is under

Following these instructions

I create a mysql group and user:

groupadd mysql
useradd -r -g mysql mysql

I change the ownership of mysql scripts to mysql (as per the instructions, but doubt this is necesssary)

cd /usr/bin
sudo chown mysql mysq*
sudo chgrp mysql mysq*

I run mysql_install_db to set up grant tables

sudo mysql_install_db --user=mysql

I switch back to root the ownership and group of mysql scripts.

cd /usr/bin
sudo chown root mysq*
sudo chgrp root mysq*

I change the ownership and group of
to mysql. Location is

cd /var/lib
ls -l mysql
total 122896
-rw-rw-rw- 1 mysql mysql 56 Jul 26 10:17 auto.cnf
-rw-rw-rw- 1 mysql mysql 12582912 Jul 26 10:17 ibdata1
-rw-rw-rw- 1 mysql mysql 50331648 Jul 26 10:17 ib_logfile0
-rw-rw-rw- 1 mysql mysql 50331648 Jul 24 17:36 ib_logfile1
-rw-rw---- 1 mysql mysql 12582912 Jul 26 10:17 ibtmp1
drwxrwxrw- 2 mysql mysql 4096 Jul 24 17:36 mysql
drwxrw-rw- 2 mysql mysql 4096 Jul 24 17:36 performance_schema
drwxrw-rw- 2 mysql mysql 4096 Jul 24 17:36 test

Now, when I try to start the
server, I get permission errors:

mysqld_safe --user=mysql &
[4] 5680
/var/lib$ 140727 00:42:17 mysqld_safe Logging to '/var/log/mysql/error.log'.
cat: /var/run/mysqld/ Permission denied
rm: cannot remove ‘/var/run/mysqld/’: Permission denied
140727 00:42:17 mysqld_safe Fatal error: Can't remove the pid file:
Please remove it manually and start /usr/bin/mysqld_safe again;
mysqld daemon not started
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied

Similarly, if I try to start the server as root:

mysqld_safe -p -u root
140727 00:54:08 mysqld_safe Logging to '/var/log/mysql/error.log'.
140727 00:54:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
/usr/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
140727 00:54:08 mysqld_safe mysqld from pid file /var/run/mysqld/ ended
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied

Apparently there are many places where I should be changing permissions, which does not look like the way to go. Three questions:

  1. Is there some evident point where I went wrong, or should I just uninstall and apt-get everything?

  2. Should I have owner mysql and group mysql for all files that the server needs to update?

  3. Is there a comprehensive list of locations where these files are?

Answer Source

You cannot create /var/log/mysql/error.log. First create the directory if it doesn't exist

sudo mkdir -p /var/log/mysql

Next, change ownership

sudo chown -R mysql /var/log/mysql

and then try again to start the server as root:

sudo mysqld_safe --user=mysql &

If the server does not start paste here the error messages

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download