使用已有数据库
创建本地数据库
数据库:nocodb
用户:nocodb
密码:xxxxxx
dockercomposeyml_7">修改docker-compose.yml
默认网关的 IP 地址是 172.17.0.1(适用于 bridge 网络模式)
version: "2.1"
services:nocodb:environment:# 更新数据库连接信息为宿主机的 MySQLNC_DB: "mysql2://172.17.0.1:3306?u=nocodb&p=xxxxxx&d=nocodb"image: "nocodb/nocodb:latest"ports:- "28080:8080"restart: alwaysvolumes:- "/opt/ai-server/nocodb_data:/usr/app/data"
volumes:nc_data: {}
启动镜像
docker compose up -d
查看日志
docker ps
docker logs nocodb-nocodb-1 (根据上一步获取的名称来查看)
找到
[Nest] 9 - 12/27/2024, 8:02:03 AM ERROR [ExceptionHandler] Error: Access denied for user ‘nocodb’@‘172.25.0.2’ (using password: YES)
给用户授权IP访问
mysql-5.7.14mysql -h 127.0.0.1 -P 3306 -u root -p xxxxxxxx
GRANT ALL PRIVILEGES ON nocodb.* TO 'nocodb'@'172.25.0.2';
FLUSH PRIVILEGES;
等待nocodb自动重启
访问
http://127.0.0.1:28080
dockermysql_66">使用独立的docker中新的mysql
dockercomposeyml_68">配置 docker-compose.yml
version: "2.1"
services: nocodb: depends_on: root_db: condition: service_healthyenvironment: NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"image: "nocodb/nocodb:latest"ports: - "28080:8080"restart: alwaysvolumes: - "nc_data:/usr/app/data"root_db: environment: MYSQL_DATABASE: root_dbMYSQL_PASSWORD: passwordMYSQL_ROOT_PASSWORD: passwordMYSQL_USER: nocohealthcheck: retries: 10test: - CMD- mysqladmin- ping- "-h"- localhosttimeout: 20simage: "mysql:8.3.0"restart: alwaysvolumes: - "db_data:/var/lib/mysql"
volumes: db_data: {}nc_data: {}
注意修改一些敏感数据
启动
docker compose up -d
访问
http://127.0.0.1:28080