1.mysql 官网下载rpm包
官网地址 https://dev.mysql.com/
快速直达下载地址 https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar
下载完成后只要这4个rpm包
mysql-community-client-5.7.34-1.el7.x86_64.rpm
mysql-community-common-5.7.34-1.el7.x86_64.rpm
mysql-community-libs-5.7.34-1.el7.x86_64.rpm
mysql-community-server-5.7.34-1.el7.x86_64.rpm
注意如果下载地址有点慢,切换到国内镜像下载(分别找到这4个rpm包)
http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/
2.rpm包上传到服务器,并且安装
安装顺序
rpm -ivh mysql-community-common-5.7.34-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-5.7.34-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-5.7.34-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-5.7.34-1.el7.x86_64.rpm --force --nodeps
-注意 -force --nodeps 忽视 警告:mysql-community-common-5.7.34-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
3.配置mysql 启动
1. service mysqld start
2. cat /var/log/mysqld.log |grep password
3. mysql -u root -p
输入上面的密码 !lVdr%pfD3Px
4. alter user 'root'@'localhost' identified by '新的密码';
运行远程访问
5. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '新的密码' WITH GRANT OPTION;
最后
6. flush privileges;
查看权限
7. show grants;
mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
如果出现密码策略问题异常信息:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
请设置:
set global validate_password_policy=LOW;
别忘记把3306端口开放
其他相关操作
systemctl start mysqld.service 启动mysql
systemctl status mysqld.service 查看mysql状态
systemctl stop mysqld.service 关闭mysql
查看mysql进程 ps -ef|grep mysql
查看3306端口 netstat -anop|grep 3306