Ubuntu系统支持多种数据库安装方案,本文详细介绍MySQL、PostgreSQL等主流数据库的完整安装流程。

sudo apt updatesudo apt install mysql-serversudo systemctl start mysqlsudo systemctl stop mysqlsudo systemctl enable mysqlsudo mysql -u root -psudo apt updatesudo apt install postgresql postgresql-contribsudo systemctl start postgresqlsudo systemctl stop postgresqlsudo systemctl enable postgresqlsudo -u postgres psqlwget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.listsudo apt updatesudo apt install -y mongodb-orgsudo systemctl start mongodsudo systemctl stop mongodsudo systemctl enable mongodSQLite是一个嵌入式数据库,不需要单独安装。你可以直接使用SQLite命令行工具。
sudo apt updatesudo apt install sqlite3sqlite3 your_database.dbsudo apt updatesudo apt install redis-serversudo systemctl start redis-serversudo systemctl stop redis-serversudo systemctl enable redis-server本文完整演示了Ubuntu系统下五大数据库的安装方法,读者可根据实际项目需求选择适合的数据库类型进行部署使用。