centos MySQL安装与卸载
1、配置YUM源
在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/repo/yum/
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
image.png
2、安装MySQL
yum install mysql-community-server
3、启动MySQL服务
systemctl start mysqld
4、开机启动
systemctl enable mysqld systemctl daemon-reload
5、修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
set password for ‘root‘@‘localhost‘=password(‘password!‘);
image.png
6、允许远程连接
grant all on *.* to root@‘%‘ identified by ‘password‘ with grant option; flush privileges;
卸载
采用yum安装mysql后,如果想要完全卸载mysql,可以采用如下方式:
1、查看mysql安装了哪些东西
rpm -qa |grep -i mysql
image.png
2、开始卸载
yum remove mysql-community-common-5.7.20-1.el7.x86_64 yum remove mysql-community-client-5.7.20-1.el7.x86_64 yum remove mysql57-community-release-el7-11.noarch yum remove mysql-community-libs-5.7.20-1.el7.x86_64 yum removemysql-community-server-5.7.20-1.el7.x86_64
3、查看是否卸载完成
image.png
4、查找mysql相关目录
find / -name mysql
image.png
5、删除相关目录
rm -rf
image.png
6、删除/etc/my.cnf
rm -rf /etc/my.cnf
7、删除/var/log/mysqld.log(如果不删除这个文件,会导致新安装的mysql无法生存新密码,导致无法登陆)
rm -rf /var/log/mysqld.log
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11