Install
- Install dependencies
# 下载
shell> wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# 安装 mysql 源
shell> yum localinstall mysql57-community-release-el7-11.noarch.rpm
- Use the following command to check whether the mysql source is installed successfully
shell> yum repolist enabled | grep "mysql.*-community.*"
- Start mysql
yum install -y mysql-community-server
Configuration
- Start mysql. The shutdown command is (
systemctl start|stop
)
systemctl start mysqld
- View mysql status
systemctl status mysqld
- Set up auto-start at boot
systemctl enable mysqld
# 重载所有修改过的配置文件
systemctl daemon-reload
- Generate password
grep 'password' /var/log/mysqld.log
-
set password
- Login mysql
mysql -uroot -p
- set password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'ABCdef123!';
- Login mysql
-
Add an account that allows remote connections
GRANT ALL PRIVILEGES ON *.* TO 'GanYuHui'@'%' IDENTIFIED BY 'ABCdef123!' WITH GRANT OPTION;
- Allow root remote connections
use mysql;
UPDATE user SET Host='%' WHERE User='root';
flush privileges;
- Set the default encoding to utf8
vim /etc/my.cnf
# 新增配置
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
- Restart the mysql service
systemctl restart mysqld