maridb-server在centos7安装使用笔记

235 阅读2分钟

pip3 install feapder -i mirrors.aliyun.com/pypi/simple…

在centos7上安装mariadb-server,在启动过程中遇到如下错误

root@localhost:~# 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.


root@localhost:~# systemctl status mariadb.service   
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2022-10-20 15:08:58 CST; 3s ago
  Process: 60135 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=203/EXEC)

Oct 20 15:08:58 localhost.localdomain systemd[1]: Starting MariaDB database server...
Oct 20 15:08:58 localhost.localdomain systemd[60135]: Failed at step EXEC spawning /usr/libexec/mariadb-prepa...nied
Oct 20 15:08:58 localhost.localdomain systemd[1]: mariadb.service: control process exited, code=exited status=203
Oct 20 15:08:58 localhost.localdomain systemd[1]: Failed to start MariaDB database server.
Oct 20 15:08:58 localhost.localdomain systemd[1]: Unit mariadb.service entered failed state.
Oct 20 15:08:58 localhost.localdomain systemd[1]: mariadb.service failed.
Hint: Some lines were ellipsized, use -l to show in full.


root@localhost:~# /usr/libexec/mariadb-prepare-db-dir
Database MariaDB is not initialized, but the directory /var/lib/mysql is not empty, so initialization cannot be done.
Make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
root@localhost:~# 

按以上提示,将/var/lib/mysql中的文件移到其它文件夹。

root@localhost:~# mkdir /var/lib/mysql_bk
root@localhost:~# mv /var/lib/mysql/* /var/lib/mysql_bk/

还是不行。通过journalctl -xe里的报错情况来看,可能是

换了一台新虚拟机也是centos7,就好使了。

[root@centos7-126 ~]# ps -ef |grep mariadb         
root       5591   3898  0 15:46 pts/0    00:00:00 grep --color=auto mariadb
[root@centos7-126 ~]# ps -ef |grep mysql
root       5598   3898  0 15:46 pts/0    00:00:00 grep --color=auto mysql
[root@centos7-126 ~]# systemctl start mariadb
[root@centos7-126 ~]# ps -ef |grep mariadb   
mysql      5874   5708  2 15:46 ?        00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root       5921   3898  0 15:46 pts/0    00:00:00 grep --color=auto mariadb
[root@centos7-126 ~]# ps -ef |grep mysql     
mysql      5708      1  0 15:46 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql      5874   5708  2 15:46 ?        00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root       5927   3898  0 15:46 pts/0    00:00:00 grep --color=auto mysql