mariadb启动报错的一个案例

时间:2025-04-09 20:10:08

今天安装了mariadb,在启动时报错如下:

[root@iZ284mvmum4Z bin]# mysqld_safe
160608 09:18:25 mysqld_safe Logging to '/var/log/mariadb/'.
160608 09:18:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160608 09:18:26 mysqld_safe mysqld from pid file /var/run/mariadb/ ended


然后去分析报错文件,看到如下内容:

160608  9:18:26 [ERROR] Can't open the table. Please run mysql_upgrade to create it.
160608  9:18:26 [Note] Server socket created on IP: '0.0.0.0'.
160608  9:18:26 [ERROR] Fatal error: Can't open and lock privilege tables: Table '' doesn't exist
160608 09:18:26 mysqld_safe mysqld from pid file /var/run/mariadb/ ended

因为这里它报错不存在,而且无法打开表,说明此时的问题是没有安装初始的数据库,因此执行如下命令即可:

mysql_install_db --user=mysql --datadir=/usr/local/mysql/var

这里的datadir换成我们的数据存储目录即可。

然后再次启动就可以了。