我有几个中小型 mysql 数据库,比如大约 40 个,我需要将它们从一个具有不同 cpanel 帐户的 whm 服务器迁移到另一个使用从以前的服务器设置的帐户和我正在移动的旧版本数据库的服务器地方。
任何人都可以推荐这样做的最快方法,我打算手动转储每个并导入它,但这似乎非常耗时,如果可能的话,我想将我的机器作为中间人,并尽可能自动化。
我对 cPanel 了解不多,但我知道如何将数据库非常快速地传输到另一台服务器 - 如果您可以访问 ssh。
使用具有正确参数的 mysqldump 并使用 ssh 链接它。所以数据库被导入,而源数据库仍然导出。不使用临时文件(内部mysql除外;))
sourceserver# mysqldump --user=user1 --all-databases | ssh 目标主机 'mysql --user=user2'
如果您使用私钥和 ssh-agent 对源服务器进行身份验证,则可以使用 ssh 的 -A 选项进行连接。所以你不需要关心目标端的授权。但请记住:
Agent forwarding should be enabled with caution. Users with the
ability to bypass file permissions on the remote host (for the
agent's Unix-domain socket) can access the local agent through
the forwarded connection. An attacker cannot obtain key material
from the agent, however they can perform operations on the keys
that enable them to authenticate using the identities loaded into
the agent.
Run Code Online (Sandbox Code Playgroud)
(来源:man 1 ssh)
希望这个对你有帮助
| 归档时间: |
|
| 查看次数: |
4148 次 |
| 最近记录: |