- 下載安裝源
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
- 安裝rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
- 查看rpm源是否安裝成功
yum repolist enabled | grep "mysql.*-community.*"
4.安裝
yum install mysql-community-server
- 啟動(dòng)
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
systemctl daemon-reload
- 查看修改密碼
默認(rèn)密碼在/var/log/mysqld.log文件中
取得默認(rèn)密碼父虑,最好復(fù)制
grep 'temporary password' /var/log/mysqld.log
- 修改密碼
mysql -u root -p
輸入剛復(fù)制的密碼
set password for 'root'@'localhost'=password('新密碼');
- 查看和修改數(shù)據(jù)庫的默認(rèn)字符集
show variables like '%character%';
set character_set_database = utf8mb4;
9.創(chuàng)建數(shù)據(jù)庫
create database $DATABASENAME;
9.創(chuàng)建用戶
create user "username"@"host" identified by "password";
- 授權(quán)
grant all privileges on $DBNAME.* to $USER@'%' identified by '$PASSWORD';
flush privileges;