CentOS安装MySQL
-
下载并安装MySQL的yum repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
-
yum安装MySQL
yum -y install mysql57-community-release-el7-10.noarch.rpm
-
安装MySQL服务器
yum -y install mysql-community-server
-
启动MySQL
systemctl start mysqld.service
-
查看MySQL运行状态
systemctl status mysqld.service
-
获取MySQL默认密码
grep 'password' /var/log/mysqld.log
-
进入数据库
mysql -u root -p
-
修改密码
alter user 'root'@'localhost' identified by '密码'
-
修改MySQL语言
exit
vim /etc/my.cnf
添加4行内容
在最上面添加两行
[client] default-character-set=utf9
在[mysqld]中添加两行
character-set-server=utf8 collation-server=utf8_general_ci
重启mysqld.service并查看运行状态
systemctl restart mysqld.service
systemctl status mysqld.service
- 进入MySQL并查看MySQL语言
mysql -u root -p
status
Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8
- 开放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
- 重启防火墙
systemctl restart firewalld.service