Home > Software engineering >  Mysql Error while piping database to different server
Mysql Error while piping database to different server

Time:11-30

I have a strange error here. The command I am executing is this:

mysqldump -u root -ppass kodi_video119 | mysql -h192.168.178.73 -u kodi -ppass kodi_video119

When I execute it over SSH it all works fine, but when I save it to a file and execute this file I get the following error:

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

I can't find any results using google on that error number. The user is allowed to write and it all works fine when I execute it direcly from SSH. But using the same SSH session (as root user) just executing the command embedded in the file it does not work.

Whats going wrong here? I created the file using nano and saved it using nano. Then chmod x and execute ./test

CodePudding user response:

By default, when you use mysqldump DB, the output includes table-creation statements, but no CREATE DATABASE statement. It just assumes you have created an empty schema first.

So you could do this to create the schema first:

mysqladmin -h192.168.178.73 create kodi_video119
mysqldump kodi_video119 | mysql -h192.168.178.73 kodi_video119

(I left out the -u and -p options for brevity)

Alternatively, you can use the -B option, aka --databases. This option allows you to specify one or more databases, and the output includes CREATE DATABASE statements for each one before it then creates and populates tables. You can use it with a single database argument:

mysqldump -B kodi_video119 | mysql -h192.168.178.73 kodi_video119
  • Related