復(fù)制下載mysql 官方下載地址
- 打開(kāi)官網(wǎng)下載地址
安裝mysql
- 輸入命令 **下載mysql的repo源 **
wget https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm
- 輸入命令 **安裝mysql-community-release-el7-5.noarch.rpm包 **
sudo rpm -ivh mysql57-community-release-el7-10.noarch.rpm
- 輸入命令 安裝mysql
$ sudo yum install mysql-server
- 輸入命令 查看MySQL的啟動(dòng)狀態(tài)
systemctl status mysqld
- 輸入命令 啟動(dòng)MySQL服務(wù)
sudo systemctl start mysqld
- 輸入命令 查看MySQL的啟動(dòng)狀態(tài)
systemctl status mysqld
修改密碼
- 輸入命令 查看初始密碼
grep 'temporary password' /var/log/mysqld.log
- 輸入命令 登錄myql賬號(hào)
mysql -uroot -p
- 輸入命令 設(shè)置新的密碼
set password for 'root'@'localhost'=password('MyNewPass4!');
- 輸入命令 添加遠(yuǎn)程登錄用戶
GRANT ALL PRIVILEGES ON *.* TO 'youusr'@'%' IDENTIFIED BY 'Youusr0917!' WITH GRANT OPTION;
set password for 'root'@'localhost'=password('MyNewPass4!');
- 輸入命令 **退出mysql**
quit;
## 配置默認(rèn)編碼為utf8
- 輸入命令 **修改/etc/my.cnf配置文件**
sudo vi /etc/my.cnf
修改如下:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
## SQLyog客戶端遠(yuǎn)程連接mysqsl
如果你不能遠(yuǎn)程連接mysql,可以嘗試一下命令
- 輸入命令 **登錄myql賬號(hào)**
mysql -uroot -p
- 輸入命令 **開(kāi)放3306端口**
sudo vi /etc/sysconfig/iptables