Назад | Перейти на главную страницу

MySQL не запускается с изменением Datadir

Я пытаюсь изменить datadir для mysql. Когда я пытаюсь перезапустить службу, она зависает на 10 минут, а затем не запускается. Вот шаги, которые я предпринял, чтобы изменить каталог:

  1. sudo service mysqld stop
  2. sudo cp -R -p / var / lib / mysql / srv / msqyl2
  3. ls -lha / SRV / mysql2

    drwxr-xr-x. 4 mysql mysql 4.0K 24 августа 17:51 msqyl2

  1. sudo vim /etc/my.cnf
  2. Закомментируйте каталог по умолчанию, `# datadir = / var / lib / mysql`
  3. Добавьте новую строку с той же директивой, но с новым местоположением, `datadir = / srv / mysql2`
  4. служба sudo запуск mysql

Это дает мне:

Задание для mysqld.service завершилось неудачно из-за превышения таймаута. См. "Systemctl status mysqld.service" и "journalctl -xe" для подробностей.

примерно через 10 минут после обработки start. Если я переверну комментарий так, чтобы каталог был каталогом по умолчанию, то перезапуск сработает менее чем за 5 секунд.

В journalctl -xe возвращает:

Aug 24 18:35:17 uroot-ARTMO-myserver-1 systemd[1]: mysqld.service start-post operation timed out. Stopping.
Aug 24 18:35:17 uroot-ARTMO-myserver-1 systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysqld.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysqld.service has failed.
-- 
-- The result is failed.
Aug 24 18:35:17 uroot-ARTMO-myserver-1 systemd[1]: Unit mysqld.service entered failed state.
Aug 24 18:35:18 uroot-ARTMO-myserver-1 systemd[1]: mysqld.service failed.
Aug 24 18:35:18 uroot-ARTMO-myserver-1 polkitd[1309]: Unregistered Authentication Agent for unix-process:22433:121785532 (system bus name :1.833, object path /org/freedesktop/PolicyKi
Aug 24 18:35:18 uroot-ARTMO-myserver-1 systemd[1]: mysqld.service holdoff time over, scheduling restart.
Aug 24 18:35:18 uroot-ARTMO-myserver-1 systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysqld.service has begun starting up.
Aug 24 18:35:18 uroot-ARTMO-myserver-1 mysqld_safe[24090]: 160824 18:35:18 mysqld_safe Logging to '/var/log/mysqld.log'.
Aug 24 18:35:18 uroot-ARTMO-myserver-1 mysqld_safe[24090]: 160824 18:35:18 mysqld_safe Starting mysqld daemon with databases from /srv/mysql2
Aug 24 18:35:18 uroot-ARTMO-myserver-1 mysqld_safe[24090]: 160824 18:35:18 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

В systemctl status mysqld.service возвращает:

● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: activating (start-post) since Wed 2016-08-24 18:45:18 CEST; 8min ago
  Process: 26133 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
  Process: 26120 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 26133 (code=exited, status=0/SUCCESS);         : 26134 (mysql-systemd-s)
   CGroup: /system.slice/mysqld.service
           └─control
             ├─26134 /bin/bash /usr/bin/mysql-systemd-start post
             └─27942 sleep 1

Aug 24 18:45:18 uroot-ARTMO-myserver-1 systemd[1]: Starting MySQL Community Server...
Aug 24 18:45:18 uroot-ARTMO-myserver-1 mysqld_safe[26133]: 160824 18:45:18 mysqld_safe Logging to '/var/log/mysqld.log'.
Aug 24 18:45:18 uroot-ARTMO-myserver-1 mysqld_safe[26133]: 160824 18:45:18 mysqld_safe Starting mysqld daemon with databases from /srv/mysql2

Разрешения для каталога по умолчанию /var/lib/mysql является:

drwx ------. 2 MySQL, MySQL 4.0K, 18 августа, 21:32, MySQL

В mysqld.log имеет:

160824 18:35:18 mysqld_safe Starting mysqld daemon with databases from /srv/mysql2
2016-08-24 18:35:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-24 18:35:18 0 [Note] /usr/sbin/mysqld (mysqld 5.6.32) starting as process 24253 ...
2016-08-24 18:35:18 24253 [Warning] Can't create test file /srv/mysql2/uroot-ARTMO-myserver-1.lower-test
2016-08-24 18:35:18 24253 [Warning] Can't create test file /srv/mysql2/uroot-ARTMO-myserver-1.lower-test
2016-08-24 18:35:18 24253 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)

2016-08-24 18:35:18 24253 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)

2016-08-24 18:35:18 24253 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2016-08-24 18:35:18 24253 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-08-24 18:35:18 24253 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-08-24 18:35:18 24253 [Note] InnoDB: The InnoDB memory heap is disabled
2016-08-24 18:35:18 24253 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-24 18:35:18 24253 [Note] InnoDB: Memory barrier is not used
2016-08-24 18:35:18 24253 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-08-24 18:35:18 24253 [Note] InnoDB: Using Linux native AIO
2016-08-24 18:35:18 24253 [Note] InnoDB: Using CPU crc32 instructions
2016-08-24 18:35:18 24253 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-08-24 18:35:18 24253 [Note] InnoDB: Completed initialization of buffer pool
2016-08-24 18:35:18 7f32872e8740  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2016-08-24 18:35:18 24253 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
2016-08-24 18:35:18 24253 [ERROR] InnoDB: The system tablespace must be writable!
2016-08-24 18:35:18 24253 [ERROR] Plugin 'InnoDB' init function returned error.
2016-08-24 18:35:18 24253 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-08-24 18:35:18 24253 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-08-24 18:35:18 24253 [ERROR] Aborting

2016-08-24 18:35:18 24253 [Note] Binlog end
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'partition'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_METRICS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_CMPMEM'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_CMP'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_LOCKS'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'INNODB_TRX'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'BLACKHOLE'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'ARCHIVE'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'MRG_MYISAM'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'MyISAM'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'MEMORY'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'CSV'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'sha256_password'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'mysql_old_password'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'mysql_native_password'
2016-08-24 18:35:18 24253 [Note] Shutting down plugin 'binlog'
2016-08-24 18:35:18 24253 [Note] /usr/sbin/mysqld: Shutdown complete

160824 18:35:18 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Часто это происходит из-за чего-то вроде apparmor. Регистрироваться /etc/ если есть apparmor, selinux или другие профили, ограничивая mysql /var/lib/mysql.

Если команды, которые вы разместили в своем вопросе, верны, значит, у вас опечатка.

sudo cp -R -p /var/lib/mysql /srv/msqyl2
ls -lha /srv/mysql2
drwxr-xr-x. 4 mysql mysql 4.0K Aug 24 17:51 msqyl2
Add a new line with same directive but new location, `datadir=/srv/mysql2`

mysql2 не является msqyl2