centos安装mysql流程以及解决启动失败问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos安装mysql流程以及解决启动失败问题相关的知识,希望对你有一定的参考价值。
安装步骤
安装前,我们可以检测系统是否自带安装 mysql:
rpm -qa | grep mysql
如果你系统有安装,那可以选择进行卸载:
rpm -e mysql // 普通删除模式
rpm -e --nodeps mysql
安装
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server
初始化 MySQL:
mysqld --initialize
启动 MySQL:
systemctl start mysqld
查看 MySQL 运行状态:
systemctl status mysqld
centos启动mysql报错
$ systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (start-pre) since 一 2018-09-03 06:27:17 EDT; 631ms ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 26472 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Control: 26489 (mysqld_pre_syst)
Memory: 26.6M
CGroup: /system.slice/mysqld.service
└─control
├─26489 /bin/bash /usr/bin/mysqld_pre_systemd
└─26506 /usr/bin/python -Es /usr/sbin/semanage fcontext -a -e /var/lib/mysql /var/lib/mysql-files
9月 03 06:27:17 test241vm22 systemd[1]: Starting MySQL Server...
解决办法
chown mysql:mysql -R /var/lib/mysql
修改初始密码
You must reset your password using ALTER USER statement before executing this statement.
安装完mysql 之后,登陆以后,不管运行任何命令,总是提示这个
step 1: SET PASSWORD = PASSWORD(‘your new password‘);
step 2: ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
step 3: flush privileges;
创建用户,授权远程登陆
create user ‘test‘@‘10.1.3.200‘ identified by ‘123456‘;
grant all privileges on *.* to ‘sl_test‘@‘10.100.0.0‘;
flush privileges;
导入数据库
source /data/model/tables.sql
以上是关于centos安装mysql流程以及解决启动失败问题的主要内容,如果未能解决你的问题,请参考以下文章
阿里云CentOS 7.2 MySQL服务启动失败的解决思路
解决Linux-Centos7启动Mysql服务失败丢失mysql.sock问题