Background
这里我们把rpm包下载下来,下载地址(https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm),离线安装yum源,然后使用yum安装,使用yum安装的好处在于,它会自动安装依赖包,以及替换包(例如CentOS7自带的mariadb-libs.x86_64 1:5.5.60-1.el7_5),操作记录如下:
1 安装yum源
将下载的rpm包上传到服务器上,然后执行如下命令安装
rpm -ivh mysql57-community-release-el7-10.noarch.rpm
2 查看yum源
将下载的rpm包上传到服务器上,然后执行如下命令安装
yum list | grep mysql-community-server
3 安装MySQL
将下载的rpm包上传到服务器上,然后执行如下命令安装
yum -y install mysql-community-server
4 启动MySQL,并查看状态
service mysqld start
service mysqld status
5 取消密码复杂度
vi /etc/my.cnf
# 在 [mysqld] 后添加如下三行
skip-grant-tables # 免密登录
plugin-load=validate_password.so
validate-password=OFF
6 免密登录上修改密码
mysql> use mysql;
mysql> update user set authentication_string=password("root") where user="root";
mysql> FLUSH PRIVILEGES;
7 如果登陆过期需要再次修改
mysql> alter user user() identified by "root";
8 赋权远程访问
mysql> use mysql;
mysql> delete from user where user<>"root";
mysql> update user set host="%" where user="root";
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
mysql> FLUSH PRIVILEGES;
mysql> select user, host, authentication_string from user;