Linux安装mysql(虚拟机适用)

更新包

复制代码
 sudo apt update

安装mysql服务

复制代码
sudo apt install mysql-server

启动mysql服务

复制代码
sudo systemctl start mysql

确定mysql运行状态

复制代码
systemctl status mysql

安全相关限制,新版本mysql有安全策略,不建议用root作为密码,改成数字+字母组合较好

复制代码
sudo mysql_secure_installation

进入mysql

复制代码
sudo  mysql -u root -p

设置可以远程访问

复制代码
use mysql;
update user set host = '%' where user = 'root';
flush privileges;

查看修改结果

复制代码
select host,user,authentication_string from user;

重启mysql

开放相关端口

复制代码
cd /etc/mysql/mysql.conf.d

修改文件内容为

复制代码
bind-address		= 0.0.0.0
mysqlx-bind-address	= 0.0.0.0

重启mysql

如果还未开放系统的3306端口

复制代码
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports

更改MySQL安全策略(试了,没啥用,不推荐)

复制代码
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password.policy = LOW;
SET GLOBAL validate_password.length = 6;
相关推荐
orion5710 小时前
Missing Semester Class1:course overview and introduction of shell
linux
用户1204872216116 小时前
Linux驱动编译与加载
linux·嵌入式
这个DBA有点耶17 小时前
SQL改写进阶:标量子查询的“隐形代价”与消除实战
数据库·mysql·架构
smallyoung18 小时前
数据库乐观锁深度解析:MySQL、PostgreSQL 实战 + Spring Boot 集成指南
数据库·mysql·postgresql
用户805533698031 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698031 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
数据技术说1 天前
MySQL 迁移实战——如何实现真正的"零改造"平滑切换
mysql
七歌杜金房1 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia2 天前
linux curl命令详解_curl详解
linux
扛枪的书生3 天前
Linux 网络管理器用法速查
linux