主题
启动与停止服务
安装完成 MariaDB 后,通常需要启动服务才能使用数据库。你还需要掌握如何停止、重启以及查看服务状态。
1. 使用 systemd 管理(大多数现代 Linux 系统)
启动 MariaDB:
bash
sudo systemctl start mariadb
停止 MariaDB:
bash
sudo systemctl stop mariadb
重启 MariaDB:
bash
sudo systemctl restart mariadb
查看状态:
bash
sudo systemctl status mariadb
设置开机自启:
bash
sudo systemctl enable mariadb
取消开机自启:
bash
sudo systemctl disable mariadb
2. 使用 service 命令(部分旧系统)
bash
sudo service mariadb start
sudo service mariadb stop
sudo service mariadb restart
sudo service mariadb status
3. Windows 下的服务管理
在 Windows 中,MariaDB 安装后作为一个服务运行。
启动服务:
powershell
net start MariaDB
停止服务:
powershell
net stop MariaDB
也可以通过“服务管理器”图形界面手动控制 MariaDB 的运行状态。
掌握服务的启动与停止操作,是使用 MariaDB 的基本前提,对于系统维护和故障排查非常关键。