Database MariaDB is not initialized, but the directory /var/lib/mysql is not empty

May  1 23:10:17 test3 mariadb-prepare-db-dir: Database MariaDB is not initialized, but the directory /var/lib/mysql is not empty, so initialization cannot be done.
May  1 23:10:17 test3 mariadb-prepare-db-dir: Make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
May  1 23:10:17 test3 systemd: mariadb.service: control process exited, code=exited status=1
May  1 23:10:17 test3 systemd: Failed to start MariaDB database server.
May  1 23:10:17 test3 systemd: Unit mariadb.service entered failed state.
May  1 23:10:17 test3 systemd: mariadb.service failed

重装mariadb后,启动不了。。。

这个错误可能是由于MariaDB未能正确初始化导致的。尝试以下步骤:

1. 停止MariaDB服务:

sudo systemctl stop mariadb

2. 删除/var/lib/mysql目录中的所有文件:

sudo rm -rf /var/lib/mysql/*

3. 重新初始化MariaDB:

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

4. 启动MariaDB服务:

sudo systemctl start mariadb

5. 设置MariaDB的root密码:

sudo mysql_secure_installation

这应该解决问题并允许您使用MariaDB。

你可能感兴趣的:(数据库,mysql,mariadb)