1、下载mysql yum源
wget https://mirrors.ustc.edu.cn/mysql-repo/mysql57-community-release-el7-9.noarch.rpm
2、安装mysql yum源
yum localinstall mysql57-community-release-el7-9.noarch.rpm
3、安装mysql
yum install mysql-community-server -y
4、启动mysql服务并设置开机启动
service mysqld start
chkconfig mysqld on
5、获取临时密码
grep 'temporary password' /var/log/mysqld.log
6、使用临时密码登录
mysql -uroot -p
输入临时密码
7、设置密码
set global validate_password_policy=0;
set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
8、修改远程访问权限,不然用工具连接不上
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
9、设置字符集
vim /etc/my.cnf
#在[mysqld]部分添加:
character-set-server=utf8
#在文件末尾新增[client]段,并在[client]段添加:
[client]
default-character-set=utf8
转载请注明原文地址:https://ipadbbs.8miu.com/read-59360.html