Loading

Centos下安装Mysql5.7

卸载已安装的Mysql

yum -y remove mysql-libs

安装依赖

yum -y install numactl-libs

下载安装包(旧版本可能无法下载,可以再这里查询最新版本:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

注意:版本号后面的el7表示Red Hat Enterprise Linux 7 / Oracle Linux 7,修改为6即表Red Hat Enterprise Linux 6 / Oracle Linux 6

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;

还可以使用下面的语句来强制用户使用SSL

alter user 'test'@'%' REQUIRE SSL;

设置开机自启

chkconfig mysqld on

修改mysql配置

vim /etc/my.cnf

修改为

[client]
port=3306
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
port=3306
character-set-client-handshake=0
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
default-time-zone='+8:00'
lower_case_table_names=1
log-bin=mysql-bin
binlog-format=ROW
server_id=1
max_connections=1000
max_allowed_packet=100M

 

posted @ 2017-09-25 17:47  hackyo  阅读(482)  评论(0编辑  收藏  举报