首先,我们需要对Linux的下载源进行替换,不然在下载时会非常的慢。
首先我们先把原来的源备份,使用cd /etc/yum.repos.d/进入目录下
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d//CentOS-Base.repo.backup
进行源备份,然后下载新的源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
修改源里面的配置
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
下载:yum makecache
没有wget命令的,下载wget,我一般不查看是否有此命令,直接下,已经有的就不会下载了
yum install wget
下载完之后,下载MySQL
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
安装yum Repository
yum -y install mysql57-community-release-el7-10.noarch.rpm
使用yum安装mysql5.7
yum -y install mysql-community-server
安装完了就可以卸载yum Repository了
yum -y remove mysql57-community-release-el7-10.noarch
启动MySQL
systemctl start mysqld
设置为开机自启
systemctl enable mysqld
获取临时密码
grep "password" /var/log/mysqld.log
连接MySQL
关闭密码复杂度验证
set global validate_password_policy=0;
set global validate_password_length=1;
修改密码:
alter user user() identified by "123456";
修改权限,让root用户远程登录
show databases;
use mysql;
show tables;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
查看编码方式
Show variables like “%char%”;
修改mysql 编码,
Vim /etc/my.cnf
添加代码
[client]
default-character-set = utf8mb4
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
重启mysql
登录查看编码方式