V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
ywt474000158
V2EX  ›  MySQL

如何用正则导出多个表

  •  
  •   ywt474000158 · 2017-02-28 21:54:51 +08:00 · 3084 次点击
    这是一个创建于 2585 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如我想导出(dbname 的 test_1, test_2, test_3, test_4 ...)

    mysqldump -u root -p123456 dbname test_* > mysql.sql

    有没有这样的用法啊
    5 条回复    2017-03-01 00:06:16 +08:00
    zbinlin
        1
    zbinlin  
       2017-02-28 22:25:48 +08:00
    加 --databases 参数?
    mysqldump -u root -p123456 --databases dbname test_* > mysql.sql
    ywt474000158
        2
    ywt474000158  
    OP
       2017-02-28 22:42:33 +08:00
    @zbinlin 好像是不能用通配符,写一个文件再用文件去导出表应该是靠谱的做法。
    py123456
        3
    py123456  
       2017-02-28 23:10:10 +08:00   ❤️ 2
    mysql -uroot -p123456 dbname -e "show tables like 'test_%'"|egrep "test_[0-9]+"|xargs mysqldump -uroot -p123456 dbname > dbname.sql
    ywt474000158
        4
    ywt474000158  
    OP
       2017-03-01 00:01:36 +08:00
    @py123456 这个可以,多谢啦。
    zbinlin
        5
    zbinlin  
       2017-03-01 00:06:16 +08:00
    @ywt474000158 看错了,看成导出多个 db 了 /汗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3083 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 10:58 · PVG 18:58 · LAX 03:58 · JFK 06:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.