查看mysql文件
rpm -qa | grep mysql
下载环境
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
执行环境
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
安装
yum install mysql-server
mysql -V
service mysqld start
service mysqld status
重启
service mysqld restart
进入mysql
查看初始密码
grep "password" /var/log/mysqld.log
mysql -uroot -p')pyaL.S+I6k.'
修改密码
SET PASSWORD = PASSWORD('Admin123.0');
永不过期
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
创建外网访问root账户 xxxxxx(password)
输入你的密码
grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx(password)' with grant option;
更新
flush privileges;
查看数据库
show databases;
使用数据库
use mysql
看表
show tables;
查看远程 IP
select user,host from user;
修改用户的host
update user set host="%" where user="root";
退出
exit;
重启
service mysqld restart
部署端口:
1 登录控制台->安全组->配置规则->添加安全组->设置数据库默认的3306端口号,访问对象设置为 0.0.0.0/0
2 cmd设置防火墙
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd 常用命令请见:firewall-cmd
卸载
- 快速删除
yum remove mysql mysql-server mysql-libs mysql-server
- 查找残留文件
rpm -qa | grep -i mysql
将查询出来的文件删除
yum remove mysql-community-common-5.7.20-1.el6.x86_64
删除残余目录
whereis mysql
rm –rf /usr/lib64/mysql
- 删除依赖
## 查找依赖
yum list installed | grep mysql
## 删除找到的依赖
yum -y remove mysql-libs.x86_64
出现错误
解决:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-server