1.mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2.安装MySQL源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.检查MySQL源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
4.安装MySQL
yum install mysql-community-server
5.启动MySQL服务
systemctl start mysqld
6.查看MySQL的启动状态
systemctl status mysqld
7.开机启动
systemctl enable mysqld
systemctl daemon-reload
8.修改root本地登陆密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改
grep 'temporary password' /var/log/mysqld.log
9.关闭密码策略, 在/etc/my.cnf文件添加
validate_password = off
10.重新启动mysql服务使配置生效
systemctl restart mysqld
11.登陆MySQL
mysql -uroot -p
12.再修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
或
set password for 'root'@'localhost'=password('root');
13.打开远程访问权限
grant all privileges on *.* to 'root' @'%' identified by 'root';
flush privileges;
14.配置默认编码为utf8
修改/etc/my.cnf配置文件,添加
init_connect='SET NAMES utf8'
15.查看修改结果
show variables like '%character%'
CenOS7 安装MySQL5.7
最新推荐文章于 2024-04-25 22:58:31 发布