惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
博客园 - 聂微东
Application and Cybersecurity Blog
Application and Cybersecurity Blog
MyScale Blog
MyScale Blog
罗磊的独立博客
H
Help Net Security
L
LangChain Blog
T
Threat Research - Cisco Blogs
量子位
S
Securelist
Last Week in AI
Last Week in AI
L
Lohrmann on Cybersecurity
T
The Exploit Database - CXSecurity.com
P
Privacy International News Feed
The Hacker News
The Hacker News
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Blog of Author Tim Ferriss
T
Threatpost
Security Latest
Security Latest
P
Palo Alto Networks Blog
Microsoft Security Blog
Microsoft Security Blog
NISL@THU
NISL@THU
F
Full Disclosure
WordPress大学
WordPress大学
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Heimdal Security Blog
J
Java Code Geeks
Recorded Future
Recorded Future
Hugging Face - Blog
Hugging Face - Blog
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
阮一峰的网络日志
阮一峰的网络日志
U
Unit 42
B
Blog RSS Feed
月光博客
月光博客
C
Cisco Blogs
V
Visual Studio Blog
D
DataBreaches.Net
H
Hacker News: Front Page
博客园 - 叶小钗
N
News and Events Feed by Topic
爱范儿
爱范儿
A
Arctic Wolf

补陋阁 RSS 2.0

补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁
补陋阁
补陋阁 · 2025-11-25 · via 补陋阁 RSS 2.0

起因

之前改博客都是直接在生产环节直接操作Mysql库,最近再重构和修改BUG,所以打算本地也搭建一个Mysql,但是不想用安装包的方式安装,就使用了docker安装在本地。电脑上使用的DataGrip来管理数据库的,他没办法像Navicat直接远端拷贝过来,所以想办法弄一个快速同步的方案。

过程

搭建本地mysql

services:
  mysql:
    image: mysql:8.0.41
    container_name: mysql8
    restart: unless-stopped
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword123
      MYSQL_DATABASE: nuxt3_blog
      MYSQL_USER: myuser
      MYSQL_PASSWORD: mypassword

执行docker compose -f mysql_docker.yml up -d创建容器

# 远端数据库配置
REMOTE_HOST=10.0.0.8
REMOTE_PORT=3306
REMOTE_DB=prod_db
REMOTE_USER=admin
REMOTE_PASS='Abc123!'

# 本地 docker 容器 MySQL 配置
LOCAL_CONTAINER=mysql8
LOCAL_DB=mydatabase
LOCAL_USER=myuser
LOCAL_PASS='mypassword'

设置后,你只需执行:

docker exec -i "$LOCAL_CONTAINER" sh -c \
  "mysqldump -h $REMOTE_HOST -P$REMOTE_PORT -u $REMOTE_USER -p$REMOTE_PASS $REMOTE_DB" \
  | docker exec -i "$LOCAL_CONTAINER" mysql -u "$LOCAL_USER" -p"$LOCAL_PASS" "$LOCAL_DB"

即可自动完成远端 → 本地容器的导入。