一、资源地址
下载地址 https://dev.mysql.com/downloads/mysql/
二、安装前准备,卸载自带的 mariadb,安装依赖环境
列出已安装的 mariadb
[[email protected] ~]# rpm -qa | grep mariadb mariadb-libs-5.5.60-1.el7_5.x86_64 方法一:rpm -e --nodeps 卸载 mariadb [[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64 方法二:yum -y remove 卸载 mariadb [[email protected] ~]# yum -y remove mariadb-libs-5.5.60-1.el7_5.x86_64
如果有多余的残留目录删除它,没有则跳过
[[email protected] ~]# find / -name mysql -print 如下: [[email protected] ~]# rm -rf /var/lib/mysql [[email protected] ~]# rm -rf /var/lib/mysql/mysql [[email protected] ~]# rm -rf /usr/bin/mysql [[email protected] ~]# rm -rf /usr/lib64/mysql
安装基础软件。
[[email protected] ~]# yum -y install wget (如果你不用ftp或者lrzsz上传) [[email protected] ~]# yum -y install lrzsz (简单好用的上传下载软件) [[email protected] ~]# yum -y install vim
安装依赖软件。
[[email protected] ~]# yum -y install net-tools [[email protected] ~]# yum -y install openssl openssl-devel [[email protected] ~]# yum -y install libaio libaio-devel [[email protected] ~]# yum -y install perl perl-devel [[email protected] ~]# yum -y install perl-JSON.noarch [[email protected] ~]# yum -y install autoconf
三、查看、关闭 firewall 防火墙
[[email protected] home]# firewall-cmd --state [[email protected] home]# systemctl stop firewalld.service [[email protected] home]# systemctl disable firewalld.service
四、关闭selinux,进入到/etc/selinux/config文件,将SELINUX=enforcing 改为SELINUX=disabled
[[email protected] home]# vi /etc/selinux/config
五、重启 CentOS…
[[email protected] home]# reboot
六、上传mysql的tar包,解压tar包
[[email protected] ~]# cd /home [[email protected] home]# tar -xvf mysql-8.0.17-1.el7.x86_64.rpm-bundle.tar [[email protected] mysql]# ls -lShr
七、开始安装mysql
PS:注意安装顺序 common -> libs -> client -> server [[email protected] mysql]# rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm [[email protected] mysql]# rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm [[email protected] mysql]# rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm [[email protected] mysql]# rpm -ivh mysql-community-server-8.0.17-1.el7.x86_64.rpm [[email protected] mysql]# rpm -ivh mysql-community-libs-compat-8.0.17-1.el7.x86_64.rpm(可选) [[email protected] mysql]# rpm -ivh mysql-community-devel-8.0.17-1.el7.x86_64.rpm(可选) [[email protected] mysql]# rpm -ivh mysql-community-embedded-compat-8.0.17-1.el7.x86_64.rpm(可选) [[email protected] mysql]# rpm -ivh mysql-community-test-8.0.17-1.el7.x86_64.rpm(可选) [[email protected] mysql]# rpm -qa | grep mysql
八、初始化数据库,目录授权,启动mysql服务 [注意操作顺序]
[[email protected] mysql]# mysqld --initialize --console [[email protected] mysql]# chown -R mysql:mysql /var/lib/mysql/ [[email protected] mysql]# systemctl start mysqld
九、查看是否启动成功,active (running)
[[email protected] mysql]# mysqld --initialize --console [[email protected] mysql]# chown -R mysql:mysql /var/lib/mysql/ [[email protected] mysql]# systemctl start mysqld
十、查看初始化后的临时密码
[[email protected] mysql]# grep ‘temporary password‘ /var/log/mysqld.log 或者 [[email protected] mysql]# cat /var/log/mysqld.log | grep ‘temporary password‘
十一、登录mysql
[[email protected] home]# mysql -u root -p Enter password: 直接粘贴初始密码 ,回车确认
十二、修改初始密码,授权远程登录
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘HomeTest$2019‘; (修改 “HomeTest$2019” 为你自己的密码) mysql> use mysql; (切换到mysql库) mysql> update user set host = "%" where user=‘root‘; (授权远程登录) mysql> flush privileges; (刷新) mysql> quit; (退出登录)
十三、测试连接是否正常
安装完毕
原文链接:https://blog.csdn.net/Airmoer/article/details/100012216
原文地址:https://www.cnblogs.com/tongcharge/p/11790316.html
时间: 2024-10-09 03:10:33