1

I just copied my old set of databases to /var/lib/mysql and got something strange. First the permissions were "root:root", because I used "sudo mc" to copy the backup from backup location. I ran chmod and chown to fit the old permissions and even compared with a clean installation on another computer and the permissions should be fine. However, I still get the message that mysqld can't chdir to /var/lib/mysql

Here the console output:

thopiekar@gate:~$ sudo systemctl status mysql
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Di 2016-05-03 22:44:07 CEST; 15s ago
  Process: 9760 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 9754 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 9760 (code=exited, status=1/FAILURE);         : 9761 (mysql-systemd-s)
    Tasks: 2 (limit: 512)
   CGroup: /system.slice/mysql.service
           └─control
             ├─9761 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─9894 sleep 1

Mai 03 22:44:07 gate systemd[1]: Stopped MySQL Community Server.
Mai 03 22:44:07 gate systemd[1]: Starting MySQL Community Server...
Mai 03 22:44:08 gate mysqld[9760]: mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)
Mai 03 22:44:08 gate mysqld[9760]: 2016-05-03T20:44:08.130902Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
Mai 03 22:44:08 gate mysqld[9760]: 2016-05-03T20:44:08.131097Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
Mai 03 22:44:08 gate mysqld[9760]: 2016-05-03T20:44:08.274970Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
Mai 03 22:44:08 gate mysqld[9760]: 2016-05-03T20:44:08.275222Z 0 [Warning] Can't create test file /var/lib/mysql/gate.lower-test
Mai 03 22:44:08 gate mysqld[9760]: 2016-05-03T20:44:08.275449Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.11-0ubuntu6) starting as process 9760 ...
Mai 03 22:44:08 gate mysqld[9760]: 2016-05-03T20:44:08.285371Z 0 [Warning] Can't create test file /var/lib/mysql/gate.lower-test
Mai 03 22:44:08 gate systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
thopiekar@gate:~$ sudo ls -la /var/lib/mysql/
insgesamt 145460
drw-r-----  8 mysql mysql     4096 Mai  3 22:29 .
drwxr-xr-x 87 root  root      4096 Apr 30 00:05 ..
-rw-r-----  1 mysql mysql       56 Apr 30 00:06 auto.cnf
-rw-r-----  1 mysql mysql        0 Apr 30 00:06 debian-5.7.flag
-rw-r-----  1 mysql mysql      657 Mai  2 10:33 ib_buffer_pool
-rw-r-----  1 mysql mysql 35651584 Mai  2 10:33 ibdata1
-rw-r-----  1 mysql mysql 50331648 Mai  3 22:29 ib_logfile0
-rw-r-----  1 mysql mysql 50331648 Apr 29 15:08 ib_logfile1
-rw-r-----  1 mysql mysql 12582912 Mai  3 22:29 ibtmp1
drwxr-x---  2 mysql mysql     4096 Apr 30 00:06 mysql
drwxr-x---  2 mysql mysql     4096 Mai  2 09:46 MXYZ
drwxr-x---  2 mysql mysql     4096 Apr 30 00:06 performance_schema
drwxr-x---  2 mysql mysql    12288 Apr 30 00:06 sys
drwxr-x---  2 mysql mysql     4096 Apr 29 15:08 XY
drwxr-x---  2 mysql mysql     4096 Apr 29 15:08 XYZ

Can someone explain me this? Thanks!

0

You stated that you "just copied my old set of databases" The word "copying" in this situation could imply an incorrect approach. Of course your "copying" may have involved other undisclosed steps. MySQL seems to be structured to export your databases and to then import them into the "new" database. Not actual copying.

Do you still have your original MySQL configuration operational? Are the databases still there and accessible?

Do you have MySQL installed on your "new" system?

Do you have phpMyAdmin installed? If not look into how to use mysqldump.

If phpMyAdmin is available, use phpMyAdmin to export your databases. After that copy the output to the download folder of the "new" computer system.

On the "new" computer system, again use phpMyAdmin, but in this case, to import the databases from the download folder. Importing your databases should resolve your permissions problem.

For additional more in-depth guidance on how to export/import do an internet search on "mysql exporting databases".

Here is a random pick example based on using mysqldump: "Export and Import all MySQL databases at one time"

2
  • No, I have the old mysqld.cnf but there was only one option that was different. They just renamed one variable. I worry only about Mai 03 22:44:08 gate mysqld[9760]: mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied). As systemd starts the server as user mysql I don't see any reason after checking with sudo ls -la why mysqld has no permissions to chdir into /var/lib/mysql. – thopiekar May 4 '16 at 6:55
  • Other than to try an export/import operation as an experiment to see what happens, I have no further suggestions. – Steve R. May 4 '16 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.