centos7 mysql 数据库安装与卸载

1.下载mysql的repo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm /etc/yum.repos.d/ambari.repo

 

2.安装mysql-community-release-el7-5.noarch.rpm包

rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。

 

3.安装mysql

yum install mysql-server

 

4.重新启动MySQL服务

systemctl restart mysqld

 

5.重置密码

mysql -u root

use mysql;

update user set password=password('123456') where user='root';

GRANT all privileges on *.* TO 'root'@'%' identified by '123456' WITH GRANT OPTION;

GRANT all privileges on *.* TO 'root'@'localhost' identified by '123456' WITH GRANT OPTION;

flush privileges;  --刷新权限

 

6.重启服务,添加hive用户

systemctl restart mysqld

mysql -u root –p(使用root用户创建ambari用户并赋予权限)

create user 'ambari' identified by 'ambari';

GRANT all privileges on *.* TO 'ambari'@'%' identified by 'ambari' WITH GRANT OPTION;

GRANT all privileges on *.* TO 'ambari'@'localhost' identified by 'ambari' WITH GRANT OPTION;

GRANT all privileges on *.* TO 'ambari'@'master' identified by 'ambari' WITH GRANT OPTION;

flush privileges;

 

 

 

卸载mysql

 

yum remove mysql

 

rm -rf /var/lib/mysql

 

rpm -qa|grep mysql

         

        yum remove相关服务,如下:

yum remove -y mysql-community-release-el7-5.noarch

yum remove -y mysql-community-libs-5.6.38-2.el7.x86_64

yum remove -y mysql-community-common-5.6.38-2.el7.x86_64

 

 

rm -rf /usr/lib/mysql

rm -rf /usr/share/mysql

rm -rf /usr/my.cnf

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值