mysql 安装和删除操作
删除mysql
【第一步卸载mysql组件】
【 查看MySQL组件 】
[root@localhost ~]# rpm -qa | grep -i mysql
mysql-community-libs-8.0.12-1.el7.x86_64
mysql-community-common-8.0.12-1.el7.x86_64
mysql-community-client-8.0.12-1.el7.x86_64
mysql-community-server-8.0.12-1.el7.x86_64
【删除】
[root@localhost ~]# rpm -ev mysql-community-server-8.0.12-1.el7.x86_64
Preparing packages...
mysql-community-server-8.0.12-1.el7.x86_64
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
【删除】
[root@localhost ~]# rpm -ev mysql-community-client-8.0.12-1.el7.x86_64
Preparing packages...
mysql-community-client-8.0.12-1.el7.x86_64
【删除失败】
[root@localhost ~]# rpm -ev mysql-community-common-8.0.12-1.el7.x86_64
error: Failed dependencies:
mysql-community-common(x86-64) >= 8.0.0 is needed by (installed) mysql-community-libs-8.0.12-1.el7.x86_64
【继续查看】
[root@localhost ~]# rpm -qa | grep -i mysql
mysql-community-libs-8.0.12-1.el7.x86_64
mysql-community-common-8.0.12-1.el7.x86_64
【删除】
[root@localhost ~]# rpm -e --noscripts mysql-community-libs-8.0.12-1.el7.x86_64
[root@localhost ~]#
【删除】
[root@localhost ~]# rpm -e --noscripts mysql-community-common-8.0.12-1.el7.x86_64
[root@localhost ~]#
【查看】
[root@localhost ~]# rpm -qa | grep -i mysql
[root@localhost ~]#
【第二步:删除相关目录】
【查看】
[root@localhost ~]# find / -name mysql
/etc/mysql
/etc/selinux/targeted/active/modules/100/mysql
/var/lib/mysql
/var/lib/mysql/mysql
【删除】
[root@localhost ~]# rm -rf /etc/mysql
[root@localhost ~]# rm -rf /etc/selinux/targeted/active/modules/100/mysql
[root@localhost ~]# rm -rf /var/lib/mysql
[root@localhost ~]# find / -name mysql
【再次检查,什么都没有说明卸载成功了】
[root@localhost ~]# rpm -qa | grep -i mysql
[root@localhost ~]#
安装
* 首先下载mysql8 到本地服务器
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
> 如果想通过yum源进行安装 可以 yum localinstall mysql80-community-release-el7-1.noarch.rpm 将本地安装到yum源上
>
安装: yum install mysql-community-server
>
启动:service mysqld start
>
查看状态:service mysqld status
>
查看临时密码: cat /var/log/mysqld.log | grep password
>
登陆:mysql -u root -p 然后输入密码
>
修改密码:ALTER USER “root”@“localhost” IDENTIFIED BY “set@sun!123”;
如果想用简单密码需要修改密码规则
*set global validate_password.policy=0;
*set global validate_password.length=1;
>
退出使用新密码重新登录
>
授权远程登录
* 选择数据库 use mysql show tables;可以看到很多表
* 查看规则 select host,user from user;
* 修改规则 update user set host= ‘%’ where user = ‘root’;
* 刷新权限 flush privileges;
* 测试远程登录
配置文件
* my.cnf文件 默认在/etc/my.cnf
基本操作命令
* 安装 : yum install mysql-community-server
* 启动 : service mysqld start/restart
* 停止 : service mysqld stop
* 查看状态: service mysqld status
记录内网安装mysql的坑_正确删除安装