MySql安装
1、下载mysql安装包
再mysql官方下载安装包
2、删除依赖包
# 查找依赖包
rpm -qa | grep mysql
rpm -qa | grep MySQL
rpm -qa | grep mariadb
# 删除查询到的依赖包
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
3、安装mysql
# 将安装包上传到linux中
mysql-community-client-5.7.37-1.el7.x86_64.rpm
mysql-community-common-5.7.37-1.el7.x86_64.rpm
mysql-community-libs-5.7.37-1.el7.x86_64.rpm
mysql-community-server-5.7.37-1.el7.x86_64.rpm
# 安装mysql
rpm -ivh mysql-community-common-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.37-1.el7.x86_64.rpm
# 如果按照过程中出现缺少依赖,将依赖安装以下
yum -y install autoconf
yum -y install net-tools
4、启动mysql
# 启动
systemctl start mysqld
# 插入状态
systemctl status mysqld
5、修改mysql登录密码
# 获取临时密码
grep 'temporary password' /var/log/mysqld.log
# 通过临时密码登录mysql
mysql -uroot -p
# 修改密码的安全策略
set global validate_password_policy=0;
set global validate_password_length=4;
# 修改密码
set password = password('123456');
# 刷新权限
flush privileges;
# 退出
exit
6、增加外部访问权限
# 登录mysql
mysql -uroot -p123456
# 增强权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
# 刷新权限
FLUSH PRIVILEGES;
# 查看权限
select user,host,authentication_string from mysql.user;
Mysql卸载
1、停止mysql服务
systemctl stop mysqld
2、删除依赖包
rpm -qa |grep -i mysql
yum remove mysql-community mysql-community-server mysql-community-libs mysql-community-common
3、删除mysql文件
# 查找和mysql相关的所有的文件
find / -name mysql
# 删除以下目录
/etc/logrotate.d/mysql
/etc/selinux/targeted/active/modules/100/mysql
/var/lib/mysql # mysql保存数据的位置
/var/lib/mysql/mysql
/usr/bin/mysql
/usr/lib64/mysql
/usr/share/mysql