Linux安装MySQL
1.wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
2.yum -y localinstall mysql80-community-release-el7-3.noarch.rpm
3.yum -y install mysql-community-server
4.systemctl start mysqld(开启MySQL)
5.systemctl enable mysqld (设置开机启动)
6.systemctl daemon-reload (重新加载)
7.cat /var/log/mysqld.log | grep password(查看MySQL密码)
8.mysql -u root -p(通过刚才查看的密码登录到MySQL)
9.mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的新密码(包括大小写字母等)';
密码重置后输入 exit 退出 重新用新密码登录
设置远程访问:
mysql> create user 'root'@'%' identified with mysql_native_password by '你的新密码(包括大小写字母等)';
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
mysql> flush privileges;
更改MySQL字符集:
打开/etc/my.cnf
添加以下两行:
character_set_server=utf8
init_connect='SET NAMES utf8'
重启MySQL:
systemctl restart mysqld
查看下编码:
mysql> show variables like '%character%';
打开防火墙
systemctl start firewalld
查看3306端口是否打开
firewall-cmd --query-port=3306/tcp
开发3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重新加载防火墙配置
firewall-cmd --reload
在腾讯云或者阿里云安全组策略,开放3306端口。