centos安装mysql5.7

mysql5.6不支持jsonfield

如何yum安装centos5.7

添加Mysql5.7仓库

`rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm`

确认Mysql仓库成功添加

` yum repolist all | grep mysql | grep enabled`

复制代码如果展示像下面,则表示成功添加仓库:

mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 51
mysql-tools-community/x86_64 MySQL Tools Community enabled: 63
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 267

开始安装Mysql5.7

` yum -y install mysql-community-server`

启动Mysql

启动

` systemctl start mysqld`

设置系统启动时自动启动

` systemctl enable mysqld`

查看启动状态

` systemctl status mysqld`

Mysql的安全设置

CentOS上的root默认密码可以在文件/var/log/mysqld.log找到,通过下面命令可以打印出来

cat /var/log/mysqld.log | grep -i 'temporary password'

执行下面命令进行安全设置,这个命令会进行设置root密码设置,移除匿名用户,禁止root用户远程连接等

`mysql_secure_installation`

设置数据库编码为utf8

打开配置文件

` vim /etc/my.cnf`

在[mysqld],[client],[mysql]节点下添加编码设置

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

重启Mysql即可

` systemctl restart mysqld`

    A+
发布日期:2021年05月17日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: