在 Debian 上安装 sqladmin(通常指基于 Web 的 MySQL/MariaDB 管理工具,如 Adminer、phpMyAdmin,或 Python 的 SQLAdmin),需要先明确你指的是哪一种。下面我分别说明最常见的几种情况。
Adminer 是一个单文件的 SQL 管理工具,支持 MySQL/MariaDB/PostgreSQL 等。
sudo apt update
sudo apt install adminer -y
启用 Apache 配置(如果使用的是 Apache):
sudo a2enconf adminer
sudo systemctl restart apache2
访问地址:
http://服务器IP/adminer
sudo apt update
sudo apt install phpmyadmin -y
安装过程中会提示:
如果是 Apache:
sudo a2enconf phpmyadmin
sudo systemctl restart apache2
访问:
http://服务器IP/phpmyadmin
SQLAdmin 是一个用于 FastAPI 的后台管理库。
pip install sqladmin
from fastapi import FastAPI
from sqladmin import Admin, ModelView
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine("mysql+pymysql://user:password@localhost/db")
Session = sessionmaker(bind=engine)
app = FastAPI()
admin = Admin(app, engine)
然后运行 FastAPI 服务即可访问 /admin
sudo apt install mariadb-server -y
或
sudo apt install mysql-server -y
sudo apt install php php-mysql -y
为了给你更准确的步骤,请告诉我:
我可以给你一份完全匹配你环境的安装教程。