1.下载
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
- 解压
tar -xvf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
- 准备就绪 查看旧版本
1)
rpm -qa | grep mysql
如果没有继续
2) 清除yum mysql所有依赖包
yum remove mysql-libs
3) rpm -qa | grep mariadb;
卸载掉自带的mariadb
rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps
4) rpm -qa|grep libaio
如果没有就安装
yum -y install libaio
- 安装perl包
RHEL,CentOS等发行版:
sudo yum -y install perl-CPAN
Ubuntu,Debian等发行版:sudo apt-get install perl-modules
- 依赖包
dnf install ncurses-compat-libs
- 安装mysql
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
[/usr/lib/tmpfiles.d/mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.
[/usr/lib/tmpfiles.d/pesign.conf:1] Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.
/var/run/ /run
- 启动服务
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
- 登录mysql 获取临时密码
grep 'temporary password' /var/log/mysqld.log
2020-01-07T03:53:22.484179Z 1 [Note] A temporary password is generated for root@localhost: -Cro.Xv;E4_,
mysql -uroot -p
输入临时密码
输入quit 或 exit 都能退出mysql
- 更改密码安全策略
set global validate_password_policy=0;
set global validate_password_length=1;
- 重设密码
set password for root@localhost=password('111111');
set password for trader@localhost=password('111111');
- 授权远程登录
第一种(创建新用户)
//选择数据库
//查看所有用户
//创建用户
//授予远程登录权限
//刷新配置
use mysql;
select user,host from user;
create user 'trader'@'%' identified by 'trader';
grant all privileges on *.* to trader@'%' identified by 'trader';
flush privileges;
第二种 在root用户上操作
mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;
接下来就可以用新用户登录了