Centos下安装Mysql5.7

Posted hackyo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos下安装Mysql5.7相关的知识,希望对你有一定的参考价值。

升级,建议完成后重启

yum -y update

卸载已安装的mysql

yum -y remove mysql-libs

安装依赖

yum -y install numactl-libs

下载安装包

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.19-1.el7.x86_64.rpm
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.19-1.el7.x86_64.rpm
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.19-1.el7.x86_64.rpm
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-server-5.7.19-1.el7.x86_64.rpm

安装

rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm --nosignature
rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm --nosignature
rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm --nosignature
rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm --nosignature
rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm --nosignature

启动

service mysqld start

查看初始密码

grep "password" /var/log/mysqld.log

登录mysql后立即修改密码

SET PASSWORD FOR root@localhost = PASSWORD(newpass);

此处可能提示密码不符合要求,输入下列语句后重新修改密码即可

set global validate_password_policy=0;

设置开机自启

chkconfig mysqld on

修改mysql配置

vim /etc/my.cnf

修改为

[client]
port=3306
default-character-set=utf8mb4
[mysqld]
port=3306
character-set-client-handshake=0
character_set_server=utf8mb4
collation-server=utf8mb4_unicode_ci
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

以上是关于Centos下安装Mysql5.7的主要内容,如果未能解决你的问题,请参考以下文章

centos下安装python,mysql5.7以及虚拟环境

centos下安装mysql5.7

CentOS7下安装MySQL5.7安装与配置(YUM)

速看!centos7下源码安装mysql5.7

Centos7.4 版本环境下安装Mysql5.7操作记录

CentOS7下安装MySQL5.7安装与配置