文章目錄
[TOC]
一、在線安裝
1屎暇、替換網(wǎng)易yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo mirrors.163.com/.help/CentOS7-Base-163.repo
2承桥、清理緩存
yum clean all
yum makecache
3、下載rpm文件
yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
4根悼、安裝MySQL數(shù)據(jù)庫
yum install mysql-community-server -y
二凶异、本地安裝
1、上傳MySQL安裝包
下載鏈接:<a target="_blank">https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar</a>
上傳 MySQL 安裝文件上傳到 Linux 主機的 /root/mysql 目錄挤巡,然后執(zhí)行解壓縮:
tar xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar
2剩彬、安裝依賴的程序包
yum install perl -y
yum install net-tools -y
3、卸載mariadb程序包
rpm -qa|grep mariadb
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
4矿卑、安裝MySQL程序包
rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm
補充:上邊這些安裝包都在 解壓后的 MySQL 安裝包中喉恋。
5、修改MySQL目錄權(quán)限
chmod -R 777 /var/lib/mysql/
6、初始化MySQL
mysqld --initialize
chmod -R 777 /var/lib/mysql/*
三轻黑、啟動MySQL
1.1糊肤、在線安裝方式啟動MySQL
service mysql start
1.2、本地安裝方式啟動MySQL
service mysqld start
在線與本地安裝啟動的唯一區(qū)別就是 mysql 是否包含字母 d
2氓鄙、查看初始密碼
grep 'temporary password' /var/log/mysqld.log
由于我們并不知道安裝后的密碼馆揉,所以執(zhí)行如上指令后,會生成 root 的臨時密碼抖拦。
3把介、登陸數(shù)據(jù)庫之后,修改默認密碼
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
4蟋座、允許遠程使用root帳戶
use mysql;
UPDATE user SET host = '%' WHERE user ='root';
FLUSH PRIVILEGES;
5脚牍、允許遠程訪問MySQL數(shù)據(jù)庫( vi /etc/my.cnf)
character_set_server = utf8
bind-address = 0.0.0.0
修改完配置后向臀,重啟一下MySQL,service mysqld restart
6诸狭、開啟防火墻3360端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
分享副業(yè)
分享一下最近在做的副業(yè)券膀,賺點外快~