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

猜你喜欢

转载自kingding.iteye.com/blog/2404761