" />
sudo rm /var/lib/mysql/ -R
sudo rm /etc/mysql/ -R
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
sudo apt update
// 安装mysql5.7
sudo apt install mysql-server -y
dev.mysql.com/downloads/repo/apt/ 复制下载链接
// 下载
curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
// 用dpkg 安装
sudo dpkg -i mysql-apt-config*
// 更新你的库
sudo apt update
// 用第一种方法安装
sudo apt install mysql-server -y
// 查看服务启动状态
sudo systemctl status mysql.service
// 开启mysql 服务
sudo systemctl start mysql.service
sudo systemctl stop mysql.service && sudo systemctl disable mysql.service
# 确保你备份了你的数据库,以防你之后想使用它们。你可以通过运行下列命令卸载 MySQL:
sudo apt purge mysql*
# 清理依赖:
sudo apt autoremove
select count(*) from user where user=””;
delete from user where user=””;
flush privileges; (必须的)
update user set plugin = “mysql_native_password”;
use mysql;
update user set authentication_string=password("你的密码") where user='root'; //(无password字段的版本,也就是版本<=5.7的)
update user set password=password('你的密码') where user='root'; //(有password字段的版本,版本>5.7的)
update user set plugin="mysql_native_password";
flush privileges;
exit;
// 查看防火墙
// 关闭防火墙开启防火墙
//1.查看防火墙状态
systemctl status firewalld
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
//2.查看防火墙是否开机启动
systemctl is-enabled firewalld
//3.关闭防火墙
systemctl stop firewalld
systemctl stop firewalld.service
systemctl status firewalld
//4.禁用防火墙(系统启动时不启动防火墙服务)
systemctl disable firewalld
systemctl disable firewalld.service
systemctl is-enabled firewalld
// 开放3306端口
/sbin/iptables -I INPUT -p tcp –dport 3306-j ACCEPT
// 设置远程密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678';
// 查看密码策略
SHOW VARIABLES LIKE 'validate_password%';
修改密码策略:
set global validate_password_policy=LOW;
set global validate_password_length=6;
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
// 跟以下是等价的
update user set authentication_string=password("12345678") where user = "root";
flush privileges;
安全组 – 安全组规则 – 配置安全组,将 mysql 端口 3306 加入进去就行了。
以上全部内容,有新问题随时更新
评论区(0)