下載MySQL
https://dev.mysql.com/downloads/mysql/
選擇好對(duì)應(yīng)的版本蛉腌;
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar
解壓至指定目錄
tar -xvf mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar -C mysql/
建議移動(dòng)到指定目錄呀袱,并修改文件夾名稚照。
安裝響應(yīng)組件
依次安裝common鲫忍、libs冀墨、client刚夺、server四個(gè)組件献丑;
rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.15-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.15-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.15-1.el7.x86_64.rpm --nodeps --force
初始化數(shù)據(jù)庫(kù)
mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;
登錄數(shù)據(jù)庫(kù),修改密碼
查看默認(rèn)初始密碼侠姑;
cat /var/log/mysqld.log | grep password
根據(jù)該密碼登錄MySQL创橄;
必須修改初始密碼;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
添加用戶昏鹃,提供遠(yuǎn)程訪問(wèn)
create user 'caojiantao'@'%' identified with mysql_native_password by '123456';
grant all privileges on *.* to 'caojiantao'@'%' with grant option;
flush privileges;