配置yum源
下载mysql源安装包
1 | wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm |
安装mysql源
1 | yum localinstall mysql57-community-release-el7-8.noarch.rpm |
检查mysql源是否安装成功
1 | yum repolist enabled | grep "mysql.*-community.*" |
安装Mysql
1 | yum install mysql-community-server |
启动Mysql服务
1 | systemctl start mysqld |
查看mysql启动状态
1 | systemctl status mysqld |
开机启动
1 | systemctl enable mysqld |
修改默认密码和编码
修改密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
1 | grep 'temporary password' /var/log/mysqld.log |
或者
1 | set password for 'root'@'localhost'=password('MyNewPass4!'); |
修改默认编码
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
1 | [mysqld] |
修改完成重启mysql服务,通过如下命令查看mysql默认编码
1 | show variables like '%character%' |