之前用yum安装过一次MySQL,后来用rpm卸载了,还删除了所有的配置文件什么的,总之就是MySQL在我的Linux中清理得毫!无!痕!迹!然后。。。最近要使用MySQL了,于是我又用yum安装了一遍,但是安装好后service mysqld start失败了。。。谁让我这么折腾呢!
报错信息是这样的:
/usr/bin/mysqladmin: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
Cannot check for MySQL Daemon startup because of mysqladmin failure.
Starting mysqld: [FAILED]
于是速去百度,大神们让我:
yum remove mysql-libs #卸载
yum install -y mysql-libs #在安装
于是我右卸载重装了一遍(微笑脸)
没想到!!!还是启动失败。。。
less /var/log/mysqld.log查看了MySQL的log文件,竟然有报错。。。
这次报错是这样的:
170803 21:57:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist
170803 21:57:18 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
我又速去百度,大神说错误的意思是说安装mysql数据库后默认的表结构没有初始化,所以当你启动mysqld时,会提示说 Table ‘mysql.plugin’ doesn’t exist。因此,我们需要把mysql的默认数据结构初始化下,具体解决办法如下:
/usr/bin/mysql_install_db --user=mysql --datadir=/var/lib/mysql
我在终端输入了上述语句,MySQL终于能正常启动了!
[root@localhost bin]# service mysqld start
Starting mysqld: [ OK ]
[root@localhost bin]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.03 sec)
mysql> quit
Bye
感谢生活在互联网这么发达的二十一世纪~~~~