我想在 MySQL 旁边安装 MariaDB。在 Windows 下安装非常简单,因为只需更改端口。而在 Ubuntu 下则不同。
我按照以下步骤进行安装,但总是收到此错误消息,journalctl -xe
尽管my.cnf
已经存在并且具有探测器权限!
mysqld[26621]: Could not open required defaults file: /opt/mariadb-data/my.cnf
mysqld[26621]: Fatal error in defaults handling. Program aborted
systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mariadb.service: Unit entered failed state.
systemd[1]: mariadb.service: Failed with result 'exit-code'.
systemd[1]: mariadb.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped MariaDB Database.
安装步骤:
cd /opt
tar -zxvpf mariadb-10.2.14-linux-x86_64.tar.gz
ln -s mariadb-10.2.14-linux-x86_64 mariadb
mkdir mariadb-data
mkdir /opt/mariadb-data/tmp
groupadd --system mariadb
useradd -c "MariaDB Server" -d /opt/mariadb -g mariadb --system mariadb
cp my.cnf mariadb-data/my.cnf #see the content below
chown -R mariadb:mariadb mariadb-10.2.14-linux-x86_64/
chown -R mariadb:mariadb mariadb-data/
chmod -R 700 mariadb-data/
cd mariadb
scripts/mysql_install_db --user=mariadb --defaults-file=/opt/mariadb-data/my.cnf
cd ..
cp mariadb.service /etc/systemd/system/ #see the content below
systemctl daemon-reload
systemctl start mariadb.service
结果systemctl status mariadb.service
是:
● mariadb.service - MariaDB Database
Loaded: loaded (/etc/systemd/system/mariadb.service; static; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: inactive (dead)
systemd[1]: mariadb.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped MariaDB Database.
systemd[1]: Started MariaDB Database.
systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mariadb.service: Unit entered failed state.
systemd[1]: mariadb.service: Failed with result 'exit-code'.
systemd[1]: mariadb.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped MariaDB Database.
systemd[1]: mariadb.service: Start request repeated too quickly.
systemd[1]: Failed to start MariaDB Database.
结果/opt/mariadb/bin/mysqld_safe --user=mariadb --ledir=/opt/mariadb/bin
是:
# /opt/mariadb/bin/mysqld_safe --user=mariadb --ledir=/opt/mariadb/bin
180507 14:20:33 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
180507 14:20:33 mysqld_safe Logging to '/var/log/mysql/error.log'.
180507 14:20:33 mysqld_safe A mysqld process already exists
- /opt/mariadb-data/my.cnf
https://gist.github.com/mbnoimi/b9daceca0e0e21da86b048b9883c5edf
- /etc/systemd/system/mariadb.service
https://gist.github.com/mbnoimi/5920301ff79dcb88aab3ef7fa459733e
- 权限
/opt
Access: (0755/drwxr-xr-x) Uid: (0/root) Gid: (0/root)
- 权限
/opt/mariadb-data
Access: (0700/drwx------) Uid: (999/mariadb) Gid: (999/mariadb)
- 权限
/opt/mariadb-data/my.cnf
Access: (0700/-rwx------) Uid: (999/ mariadb) Gid: (999/ mariadb)