Centos7在线安装MySQL

wget dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum localinstall mysql57-community-release-el7-7.noarch.rpm

yum方式安装:
yum install mysql-community-server

使用tar包安装:https://www.jianshu.com/p/276d59cbc529

 登录成功后更新root用户密码:ALTER USER root@localhost IDENTIFIED  BY '123456';

贴一下/etc/my.cnf:

[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/data/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[client]
port=3306
socket=/usr/local/mysql/data/mysql.sock

[mysqld_safe]
log-error=/usr/local/mysql/data/error.log
pid-file=/usr/local/mysql/data/run/mysql.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

/etc/my.cnf.d/mysql-clients.cnf:
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#

[mysql]

[mysql_upgrade]

[mysqladmin]

[mysqlbinlog]

[mysqlcheck]

[mysqldump]

[mysqlimport]

[mysqlshow]

[mysqlslap]

 

安装完成启动时报错:

Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.]
使用: journalctl -xe命令查看时:
SELinux is preventing /usr/sbin/mysqld from write access on the directory . For complete SELinux mes

解决办法:

1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态
SELinux status:                 enabled

2、getenforce                 ##也可以用这个命令检查

关闭SELinux:

1、临时关闭(不用重启机器):


复制代码代码如下:

setenforce 0 #设置SELinux 成为permissive模式
#setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:

修改/etc/selinux/config 文件

将SELINUX=enforcing改为SELINUX=disabled

重启机器即可

 修改root用户密码时报错:

mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50638, now running 50722. Please use mysql_upgrade to fix this error.'

解决办法:使用如下命令

mysql_upgrade

再次使用命令修改密码:

/usr/bin/mysqladmin -u root password 'root'

修改成功。

posted @ 2018-05-17 14:47  做个读书人  阅读(3761)  评论(0编辑  收藏  举报