linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

时间:2022-03-06 05:52:59

linux下安装mysql数据库

linux版本:CentOS release 6.8 (Final)

mysql版本:mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

在安装数据库过成中,输入启动mysql命令:/usr/local/mysql/support-files/mysql.server start

报错信息如图:

linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

进入/usr/local/mysql/data目录下查看报错日志:

linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

经在网上查找解决方案,折腾了一翻还是不行,后来发现在初始化数据库步骤时已经就有了报错信息:

linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

是因为data文件目录下有文件,导致初始化终止,必须要在data文件目录为空的情况下,将data 目录更改为所有者为mysql,命令如下:

1.进入data目录:

linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

2.清空data目录:

linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

3.初始化数据库:

linux下安装mysql问题总结(一)mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql.pid ended

上面红色框内的是随机生成的mysql登录密码

 然后命令:/usr/local/mysql/support-files/mysql.server start,启动mysql数据库。

最后修改root密码:

# mysql –u root –p ---连接mysql,输入初始化时生成的密码

mysql> alter user 'root'@'localhost' identified by '123456';