Есть локальный сервер MariaDB на рабочем ноуте с Arch Linux, для мелких тестовых баз.
При попытке запуска – ошибка:
$ sudo systemctl start mariadb Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
Проверяем лог:
[simterm]
$ systemctl status mariadb ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2017-12-29 13:55:55 EET; 4min 53s ago Process: 7405 ExecStart=/usr/bin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE) Process: 7349 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS) Process: 7348 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Main PID: 7405 (code=exited, status=1/FAILURE) Dec 29 13:55:55 setevoy-arch-work mysqld[7405]: 2017-12-29 13:55:55 140233913434048 [Note] Recovering after a crash using mysql-bin Dec 29 13:55:55 setevoy-arch-work mysqld[7405]: 2017-12-29 13:55:55 140233913434048 [Note] Starting crash recovery... Dec 29 13:55:55 setevoy-arch-work mysqld[7405]: 2017-12-29 13:55:55 140233913434048 [Note] Crash recovery finished. Dec 29 13:55:55 setevoy-arch-work mysqld[7405]: 2017-12-29 13:55:55 140233913412352 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist Dec 29 13:55:55 setevoy-arch-work mysqld[7405]: 2017-12-29 13:55:55 140233913434048 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist Dec 29 13:55:55 setevoy-arch-work mysqld[7405]: 2017-12-29 13:55:55 140233913434048 [Note] Server socket created on IP: '::'. Dec 29 13:55:55 setevoy-arch-work mysqld[7405]: 2017-12-29 13:55:55 140233913434048 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist Dec 29 13:55:55 setevoy-arch-work systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE Dec 29 13:55:55 setevoy-arch-work systemd[1]: mariadb.service: Failed with result 'exit-code'. Dec 29 13:55:55 setevoy-arch-work systemd[1]: Failed to start MariaDB database server.
[/simterm]
Удаляем всё содержимое /var/lib/mysql/
(при условии, что базы в MySQL – тестовые, иначе – сначала делаем бекап всех баз):
[simterm]
$ sudo rm -rf /var/lib/mysql/*
[/simterm]
Устанавливаем дефолтные базы заново с помощью mysql_install_db:
[simterm]
$ sudo mysql_install_db --user=mysql --ldata=/var/lib/mysql/ --basedir=/usr/
[/simterm]
Запускаем сервис:
[simterm]
$ systemctl start mariadb
[/simterm]
Проводим обычную установку:
[simterm]
$ /usr/bin/mysql_secure_installation
[/simterm]
Подключаемся:
[simterm]
$ mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 11 Server version: 10.1.29-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
[/simterm]
Готово.