Mysql 将数据库传输到不同服务器时出错
Mysql Error while piping database to different server
我这里有一个奇怪的错误。我正在执行的命令是这样的:
mysqldump -u root -ppass kodi_video119 | mysql -h192.168.178.73 -u kodi -ppass kodi_video119
当我通过 SSH 执行它时一切正常,但是当我将它保存到一个文件并执行该文件时我收到以下错误:
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
'RROR 1102 (42000): Incorrect database name 'kodi_video119
mysqldump: Got errno 11 on write
我无法使用 google 在该错误编号上找到任何结果。允许用户写入,当我直接从 SSH 执行它时一切正常。但是使用相同的 SSH 会话(作为 root 用户)只是执行嵌入在文件中的命令是行不通的。
这里出了什么问题?我使用 nano 创建文件并使用 nano 保存它。然后chmod +x 执行./test
默认情况下,当您使用 mysqldump DB
时,输出包括 table 创建语句,但没有 CREATE DATABASE
语句。它只是假定您首先创建了一个空模式。
所以您可以先创建模式:
mysqladmin -h192.168.178.73 create kodi_video119
mysqldump kodi_video119 | mysql -h192.168.178.73 kodi_video119
(为简洁起见,我省略了 -u 和 -p 选项)
或者,您可以使用 -B
选项,又名 --databases
。此选项允许您指定一个或多个数据库,输出包括每个数据库的 CREATE DATABASE
语句,然后创建和填充 tables。您可以将它与单个数据库参数一起使用:
mysqldump -B kodi_video119 | mysql -h192.168.178.73 kodi_video119
我这里有一个奇怪的错误。我正在执行的命令是这样的:
mysqldump -u root -ppass kodi_video119 | mysql -h192.168.178.73 -u kodi -ppass kodi_video119
当我通过 SSH 执行它时一切正常,但是当我将它保存到一个文件并执行该文件时我收到以下错误:
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
'RROR 1102 (42000): Incorrect database name 'kodi_video119
mysqldump: Got errno 11 on write
我无法使用 google 在该错误编号上找到任何结果。允许用户写入,当我直接从 SSH 执行它时一切正常。但是使用相同的 SSH 会话(作为 root 用户)只是执行嵌入在文件中的命令是行不通的。
这里出了什么问题?我使用 nano 创建文件并使用 nano 保存它。然后chmod +x 执行./test
默认情况下,当您使用 mysqldump DB
时,输出包括 table 创建语句,但没有 CREATE DATABASE
语句。它只是假定您首先创建了一个空模式。
所以您可以先创建模式:
mysqladmin -h192.168.178.73 create kodi_video119
mysqldump kodi_video119 | mysql -h192.168.178.73 kodi_video119
(为简洁起见,我省略了 -u 和 -p 选项)
或者,您可以使用 -B
选项,又名 --databases
。此选项允许您指定一个或多个数据库,输出包括每个数据库的 CREATE DATABASE
语句,然后创建和填充 tables。您可以将它与单个数据库参数一起使用:
mysqldump -B kodi_video119 | mysql -h192.168.178.73 kodi_video119