Linux安装mysql服务常见错误总结

错误一:正常步骤安装完mysql,发现启动mysql服务时出现以下情况:

 遇到这样的错误,是由于 /etc/init.d/ 不存在 mysqld 这个命令(有的人安装完环境后存在,是因为你的安装包中有这样的命令将 mysql.server 文件 copy 到 /etc/init.d/ 下面了)

[root@hadoop102 mysql]# find  / -name mysql.server
/usr/local/mysql/support-files/mysql.server

然后复制刚才找到的文件到/etc/init.d/ 目录下,替换掉mysqld文件即可。

[root@hadoop102 mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
cp:是否覆盖"/etc/init.d/mysqld"? yes

重新启动服务即可。

第二个问题:

导致这个问题得原因有很多,在这里我查看了mysql的日志文件,显示出我的错误信息:

cd /var/log/
[root@hadoop102 log]# cat mysqld.log
2020-03-29T05:17:08.611117Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-03-29T05:17:08.624600Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-03-29T05:17:08.643898Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-03-29T05:17:08.670178Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-03-29T05:17:08.670335Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-03-29T05:17:08.747618Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-03-29T05:17:08.754325Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-03-29T05:17:08.754355Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-03-29T05:17:08.760900Z 0 [Note] InnoDB: Waiting for purge to start
2020-03-29T05:17:08.811363Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 2565377
2020-03-29T05:17:08.818253Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql/data/ib_buffer_pool
2020-03-29T05:17:08.818700Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-03-29T05:17:08.819204Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200329 13:17:08
2020-03-29T05:17:08.844001Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2020-03-29T05:17:08.844166Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-03-29T05:17:08.849886Z 0 [Note] IPv6 is available.
2020-03-29T05:17:08.849923Z 0 [Note]   - '::' resolves to '::';
2020-03-29T05:17:08.849940Z 0 [Note] Server socket created on IP: '::'.
2020-03-29T05:17:08.857458Z 0 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2020-03-29T05:17:08.857478Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory

很明显,错误发生在最后两行,/usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory),可能是我的这个目录下面根本没有mysqld这个文件,于是追根问底来到了/var/run文件夹下,正如预料,没有mysqld文件夹,所以创建文件夹,并且赋予权限,到此解决问题,正常启动,

[root@hadoop102 run]# ls -l mysqld*
ls: 无法访问mysqld*: 没有那个文件或目录
[root@hadoop102 run]# mkdir mysqld
[root@hadoop102 run]# chown -R mysql:mysql /var/run/mysqld
[root@hadoop102 run]# ll

错误三:

mysql服务已经正常安装,为何报出此错误?谷歌到以下两种解决办法:
第一种方式
以完整路径的方式运行命令,比如我的路径,/usr/local/mysql/bin/mysql
第二种方式用ln
ln -s /usr/local/mysql/bin/mysql /usr/bin
相当于建立一个链接文件。-s进行软链结

错误四:

这种提示通常是没有 输入密码导致的。

这个提示通常是由于输入错误密码导致的。所以下面进行修改密码:

//在配置文件中输入以下跳过身份验证,然后关闭mysql服务后再次重新启动服务。
skip-grant-tables

进入mysql修改密码

//进入mysql
mysql
//修改密码
mysql> use mysql;
set password for ‘root’@‘localhost’=password(‘root’);

如果出现以下错误信息:输入:flush privileges;

最后修改成功后别忘记进入配置文件注释掉刚才添加的内容,最后成功登陆:

 

目前遇到这两个问题,以后遇到问题在更新........

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章