rpm -qa|grep -i mysql
可以看到如下所示,说明之前安装了:
MySQL-client-5.5.25a-1.rhel5
MySQL-server-5.5.25a-1.rhel5
删除命令:
rpm -e –nodeps 包名
如: rpm -ev MySQL-client-5.5.25a-1.rhel5 rpm -ev
MySQL-server-5.5.25a-1.rhel5
find / -name mysql
查找结果如下:
[root@localhost ~]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
删除对应的mysql目录
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
注意:卸载后/etc/my.cnf不会删除,需要进行手工删除
rm -rf /etc/my.cnf
rpm -qa|grep -i mysql
无结果,说明已经卸载彻底、接下来直接安装mysql即可
[root@centos01 centos01]# rpm -aq |grep mysql
[root@centos01 centos01]# yum list installed | grep mysql
[root@centos01 centos01]# mkdir /usr/local/mysql
[root@centos01 centos01]# cd /usr/local/mysql
[root@centos01 mysql]# ll
[root@centos01 mysql]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@centos01 mysql]# ll
[root@centos01 mysql]# rpm -qpl mysql80-community-release-el7-1.noarch.rpm
[root@centos01 mysql]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm
[root@centos01 mysql]# yum list installed | grep mysql
[root@centos01 mysql]# yum repolist all | grep mysql
[root@centos01 mysql]# yum repolist enabled | grep mysql
[root@centos01 mysql]# yum install mysql-community-server //报错,用下一条替换
[root@centos01 mysql]# sudo yum install mysql-server --nogpgcheck
Is this ok [y/d/N]: y
是否继续?[y/N]:y
[centos01@centos01 ~]$ service mysqld restart
[centos01@centos01 ~]$ service mysqld status
[root@centos01 mysql]# grep 'temporary password' /var/log/mysqld.log
[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 此处是随机密码
[root@centos01 /]# service mysqld start
[root@centos01 /]# mysql -u root -p
Enter password: 填写随机密码
mysql> alter user 'root'@'localhost' identified by '新密码设置(需要复杂点)';
Query OK, 0 rows affected (0.36 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.12 |
+-----------+
1 row in set (0.00 sec)
mysql> status
mysql> create database testdb;
Query OK, 1 row affected (0.21 sec)
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| testdb |
+--------------------+
5 rows in set (0.01 sec)
mysql>
mysql> use testdb;
Database changed
mysql>
依次输入 use mysql;
和select host,user from user;
输入update user set host='%' where user='root';
命令更改权限
紧接着输入flush privileges;
命令刷新权限
输入 exit
命令退出mysql
修改防火墙配置文件:
vim /etc/firewalld/firewalld.conf
搜索:AllowZoneDrifiting
, 把对应的值 yes 改为 no
重启防护墙 即可
systemctl restart firewalld