Ubuntu 23.10下使用SQL Server的可行方案及替代方案咨询
Hey there, totally get it—having to boot back to Windows just to practice SQL is such a hassle, especially when you're in the middle of learning. Let's break down your options:
尝试在Ubuntu 23.10安装SQL Server(非官方支持,仅用于测试学习)
Since Microsoft only officially supports Ubuntu 20.04 and 22.04, you can try a workaround by forcing the use of the 22.04 repository. Keep in mind this might have compatibility issues, so don't use it for production:
- First, import Microsoft's GPG key:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg - Add the Ubuntu 22.04 SQL Server repository:
echo "deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/ubuntu/22.04/mssql-server-2022 jammy main" | sudo tee /etc/apt/sources.list.d/mssql-server.list - Update your apt cache and install:
sudo apt update sudo apt install -y mssql-server - Run the setup script to configure your instance:
sudo /opt/mssql/bin/mssql-conf setup
If you hit dependency errors or stability issues later, don't be surprised—this is an unsupported setup after all.
更稳妥的替代方案(适合SQL学习)
If you want something reliable without the hassle of unsupported setups, these options are perfect for learning:
- MySQL/MariaDB: Super popular open-source database with syntax very close to SQL Server. It's in Ubuntu's official repos, so installation is a breeze:
It's great for learning core SQL concepts, and you'll find tons of learning resources online.sudo apt install mariadb-server - PostgreSQL: A powerful, standards-compliant open-source database. It's widely used in enterprises and supports advanced SQL features. Install it with:
Perfect if you want to go beyond basic SQL and explore more advanced topics.sudo apt install postgresql postgresql-contrib - SQLite: A lightweight, file-based database that doesn't require a server. It's perfect for quickly testing SQL snippets on the fly. Ubuntu usually has it pre-installed, but if not:
Just typesudo apt install sqlite3sqlite3in your terminal to start writing SQL immediately. - Dockerized SQL Server: This is my top recommendation for learning SQL Server specifically. It uses an official container image, so it's fully supported and isolated from your system:
- Install Docker first:
sudo apt install docker.io sudo systemctl start docker && sudo systemctl enable docker - Pull the official SQL Server 2022 image:
sudo docker pull mcr.microsoft.com/mssql/server:2022-latest - Run the container (replace
YourStrong!Passw0rdwith a secure password):sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" -p 1433:1433 --name sqlserver -d mcr.microsoft.com/mssql/server:2022-latest
- Install Docker first:
No worries about your English at all—your question was clear and easy to understand!
备注:内容来源于stack exchange,提问作者Duy Nguyễn Hoàng

