MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
添加在线软件源
确保你的 sources.list 中有可用的在线镜像源。例如添加清华或阿里云镜像:
sudo nano /etc/apt/sources.list
添加Debian Trixie 官方镜像(清华源)
# Debian Trixie 官方镜像(清华源) deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ trixie-security main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ trixie-security main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
执行更新命令
sudo apt update
在线安装MariaDB数据库
sudo apt install mariadb-server mariadb-client
启动并设置为开机自启
sudo systemctl start mariadb sudo systemctl enable mariadb
进行配置,主要开放远程登录
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
修改配置,调整监听地址
bind-address = 0.0.0.0
重启数据库
sudo systemctl restart mariadb
注意:MariaDB 自 10.4+ 版本起已不再默认提供 mysql_secure_installation,你需要手动执行等效的安全配置。
因此不要再使用:sudo mysql_secure_installation,进行相关配置。
登录数据库
sudo mysql -u root -p
注意:这是通过 Unix socket 认证,不需要密码。修改密码后,再次登录需要密码。
修改密码,允许远程登录
ALTER USER 'root'@'localhost' IDENTIFIED BY '111111'; CREATE USER 'root'@'%' IDENTIFIED BY '111111'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;
注意:Debian 13 本身没有默认安装传统防火墙软件(如 firewalld 或 ufw),因此无需进行防火墙开放操作。
常用的MariaDB操作命令:
启动 MariaDB 服务:sudo systemctl start mariadb
停止 MariaDB 服务:sudo systemctl stop mariadb
重启 MariaDB 服务:sudo systemctl restart mariadb
重新加载 MariaDB 配置:sudo systemctl reload mariadb
登录 MariaDB 控制台:mysql -u root -p,然后输入您设置的密码。
退出 MariaDB 控制台:exit 或者 \q
查看 MariaDB 的状态:sudo systemctl status mariadb
查看 MariaDB 的版本:mariadb --version
Java小强
未曾清贫难成人,不经打击老天真。
自古英雄出炼狱,从来富贵入凡尘。
发表评论: