linux怎么起数据库
linux怎么起数据库详细介绍
在 Linux 系统中启动数据库,因数据库类型不同,启动方式也有所差异,下面为你介绍几种常见数据库的启动方法。
MySQL
- 确认服务状态:
bash
systemctl status mysql
若显示 active (running) ,表明 MySQL 已在运行;若显示 inactive (dead) ,则需要启动服务。
2. 启动 MySQL 服务:
bash
systemctl start mysql
- 设置开机自启:
bash
systemctl mysql
PostgreSQL
- 确认服务状态:
bash
systemctl status postgresql
若显示 active (running) ,表明 PostgreSQL 已在运行;若显示 inactive (dead) ,则需要启动服务。
2. 启动 PostgreSQL 服务:
bash
systemctl start postgresql
- 设置开机自启:
bash
systemctl postgresql
MongoDB
- 确认服务状态:
bash
systemctl status mongod
若显示 active (running) ,表明 MongoDB 已在运行;若显示 inactive (dead) ,则需要启动服务。
2. 启动 MongoDB 服务:
bash
systemctl start mongod
- 设置开机自启:
bash
systemctl mongod
Redis
- 确认服务状态:
bash
systemctl status redis-server
若显示 active (running) ,表明 Redis 已在运行;若显示 inactive (dead) ,则需要启动服务。
2. 启动 Redis 服务:
bash
systemctl start redis-server
- 设置开机自启:
bash
systemctl redis-server
912 systemctl enable redis-server
上述步骤均是以 systemd 作为服务管理工具的常见 Linux 发行版(如 Ubuntu、CentOS 7 及以上版本)为例。如果你的系统未使用 systemd ,可使用 service 命令来替代,如 sudo service mysql start 。