Centos 7 安装 mysql-8.0.22

 安装mysql

一、下载 mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar

地址:https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar

二、查找已安装的mariadb

[root@hadoop101 mysql]# rpm -qa | grep mariadb

mariadb-libs-5.5.56-2.el7.x86_64

三、卸载mariadb

方法一:rpm -e --nodeps 卸载 mariadb

[root@hadoop101 mysql]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

方法二:yum -y remove 卸载 mariadb

[root@hadoop101 mysql]# yum -y remove mariadb-libs-5.5.56-2.el7.x86_64

四、删除mysql的目录

[root@hadoop101 mysql]# find / -name mysql -print
/etc/selinux/targeted/active/modules/100/mysql
/usr/lib64/mysql
/opt/software/mysql
[root@hadoop101 mysql]# rm -rf /usr/lib64/mysql

五、安装基础工具

[root@hadoop101 mysql]# yum -y install wget
[root@hadoop101 mysql]# yum -y install lrzsz
[root@hadoop101 mysql]# yum -y install vim
[root@hadoop101 mysql]# yum -y install net-tools
[root@hadoop101 mysql]# yum -y install openssl openssl-devel
[root@hadoop101 mysql]# yum -y install libaio libaio-devel
[root@hadoop101 mysql]# yum -y install perl perl-devel
[root@hadoop101 mysql]# yum -y install perl-JSON.noarch
[root@hadoop101 mysql]# yum -y install autoconf

六、关闭防火墙 

[root@hadoop101 mysql]# firewall-cmd --state
running
[root@hadoop101 mysql]# systemctl stop firewalld
[root@hadoop101 mysql]# firewall-cmd --state
not running
[root@hadoop101 mysql]# systemctl disable firewalld.service

七、关闭selinux,进入到/etc/selinux/config文件,将SELINUX=enforcing 改为SELINUX=disabled

[root@hadoop101 mysql]# vim /etc/selinux/config

重启 CentOS…

[root@hadoop101 mysql]# reboot

八、上传mysql的tar包,解压tar包

[root@hadoop101 mysql]# tar -xvf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
[root@hadoop101 mysql]# ls –lShr
九、安装mysql 

PS:注意安装顺序 common -> client-plugins -> libs -> client -> server
[root@hadoop101 mysql]# rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm
[root@hadoop101 mysql]# rpm -ivh mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm
[root@hadoop101 mysql]# rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm
[root@hadoop101 mysql]# rpm -ivh mysql-community-client-8.0.22-1.el7.x86_64.rpm
[root@hadoop101 mysql]# rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm
[root@hadoop101 mysql]# rpm -ivh mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm(可选)
[root@hadoop101 mysql]# rpm -ivh mysql-community-devel-8.0.22-1.el7.x86_64.rpm(可选)
[root@hadoop101 mysql]# rpm -ivh mysql-community-embedded-compat-8.0.22-1.el7.x86_64.rpm(可选)
[root@hadoop101 mysql]# rpm -qa | grep mysql
mysql-community-libs-compat-8.0.22-1.el7.x86_64
mysql-community-libs-8.0.22-1.el7.x86_64
mysql-community-client-8.0.22-1.el7.x86_64
mysql-community-embedded-compat-8.0.22-1.el7.x86_64
mysql-community-common-8.0.22-1.el7.x86_64
mysql-community-server-8.0.22-1.el7.x86_64
mysql-community-client-plugins-8.0.22-1.el7.x86_64
mysql-community-devel-8.0.22-1.el7.x86_64

十、初始化数据库,目录授权,启动mysql服务,查看mysql状态 [注意操作顺序]

[root@hadoop101 mysql]# mysqld --initialize --console
[root@hadoop101 mysql]# chown -R mysql:mysql /var/lib/mysql/
[root@hadoop101 mysql]# systemctl start mysqld
[root@hadoop101 mysql]# service mysql status

查看初始化后的临时密码

[root@hadoop101 mysql]# grep 'temporary password' /var/log/mysqld.log

或者

[root@hadoop101 mysql]# cat /var/log/mysqld.log | grep 'temporary password'

十一、登录mysql

[root@hadoop101 mysql]# mysql -u root -p
Enter password: 直接粘贴初始密码 ,回车确认

十二、修改初始密码,授权远程登录

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'; (修改 “password” 为你自己的密码)
mysql> use mysql; (切换到mysql库)
mysql> update user set host = "%" where user='root'; (授权远程登录)
mysql> flush privileges; (刷新)
mysql> quit; (退出登录)

测试连接是否正常

[root@hadoop101 mysql]# mysql -u root –ppassword

连接成功,安装完毕~~撒花~~

你可能感兴趣的:(mysql,大数据)