美文网首页
数据库数据备份到云盘(mac)

数据库数据备份到云盘(mac)

作者: 斡旋_ASL | 来源:发表于2021-11-29 15:05 被阅读0次

(1)、备份数据库部分表到本地文件夹

echo off
rm -rf ~/develop/task/tmp/summary.sql
/usr/local/mysql/bin/mysqldump -uroot -proot123456 uni_app --skip-comments --skip-add-locks --no-tablespaces --skip-disable-keys > ~/develop/task/tmp/summary.sql
echo on
命令解释:
    先删除summary.sql文件,然后生成summary.sql
            上面批处理文件名称为sql.sh

(2)、mac添加定时任务

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.mx.sql.plist</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/bluestar/develop/task/sql.sh</string>
    </array>
    <key>KeepAlive</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>60</integer>
        <key>StandardErrorPath</key>
        <string>/Users/bluestar/develop/task/tmp/sql.err</string>
        <key>StandardOutPath</key>
        <string>/Users/bluestar/develop/task/tmp/sql.out</string>
</dict>
</plist>
命令解释:
            上面文件名称为com.mx.sql.plist
            路径和权限报错:sudo chown root /Library/LaunchAgents/com.mx.sql.plist
            定时备份sql服务开启命令:launchctl load ~/develop/task/com.mx.sql.plist
            定时备份sql服务关闭命令:launchctl unload ~/develop/task/com.mx.sql.plist

(3)、备份到网盘:

开通百度云盘会员
百度云盘定时备份工作空间

(4)、执行导入数据sql报错

    错误:MySQL server has gone away
     // 导入文件1000M大小文件
     set global max_allowed_packet=1024*1024*1000;

相关文章

网友评论

      本文标题:数据库数据备份到云盘(mac)

      本文链接:https://www.haomeiwen.com/subject/feklxrtx.html