安裝MySQL5.7
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
開(kāi)啟MySQL服務(wù)
開(kāi)啟MySQL服務(wù)
systemctl start mysqld
查看MySQL狀態(tài)
systemctl status mysqld
登陸MySQL
查看原始密碼
grep "password" /var/log/mysqld.log
登陸
mysql -uroot -p
修改新密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
允許root遠(yuǎn)程連接(不推薦)
use mysql;
UPDATE user SET Host='%' WHERE User='root';
flush privileges;
設(shè)置允許遠(yuǎn)程連接的賬號(hào)(推薦)
GRANT ALL PRIVILEGES ON *.* TO '用戶名'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
修改默認(rèn)編碼格式
vim /etc/my.cnf
添加以下內(nèi)容
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
重啟MySQL
systemctl restart mysqld
查看編碼格式
mysql> show variables like 'character%';