码迷,mamicode.com
首页 > 数据库 > 详细

centos安装mysql流程以及解决启动失败问题

时间:2018-09-03 21:33:57      阅读:409      评论:0      收藏:0      [点我收藏+]

标签:unit   启动失败   提示   http   password   sem   code   community   pre   

安装步骤

安装前,我们可以检测系统是否自带安装 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流程以及解决启动失败问题

标签:unit   启动失败   提示   http   password   sem   code   community   pre   

原文地址:http://blog.51cto.com/12880687/2169839

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!