0

I host my site on bluehost. I use ssh mysqldump to export database. It is unzipped or tarred. Then I use the ddev import-db

and this is the error I get

ddev import-db --src=.tarballs/xxx4_2_2022.sql ERROR at line 4200: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: ''. Failed to import database db for xxx9: ComposeCmd failed to run 'COMPOSE_PROJECT_NAME=ddev-xxx9 docker-compose -f C:\Users\xxx\ddev\xxx9.ddev.ddev-docker-compose-full.yaml exec -T db bash -c set -eu && ( mysql -uroot -proot -e "DROP DATABASE IF EXISTS db; CREATE DATABASE IF NOT EXISTS db; GRANT ALL ON db.* TO 'db'@'%';" && pv /mnt/ddev_config/.importdb3401067882/*.sql | perl -p -e 's/^(CREATE DATABASE /*|USE )[^;]*;//' | mysql db)', action='[exec -T db bash -c set -eu && ( mysql -uroot -proot -e "DROP DATABASE IF EXISTS db; CREATE DATABASE IF NOT EXISTS db; GRANT ALL ON db.* TO 'db'@'%';" && pv /mnt/ddev_config/.importdb3401067882/*.*sql | perl -p -e 's/^(CREATE DATABASE \/\*|USE )[^;];//' | mysql db)]', err='exit status 1', stdout='', stderr='ERROR at line 4200: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: ''.'

the site seems to be functional after failed import...everything works fine...but still I am concerned and how would I fix this? I am on win 11, using gitbash and cmder

and the site is drupal 9 latest

rfay
  • 9,963
  • 1
  • 47
  • 89
bobo
  • 71
  • 9

2 Answers2

3

the solution is to use different db import command in ddev

instead ddev import-db --src=.tarballs/junk.sql

you should use

ddev import-db <db.sql or ddev import-db < .tarballs/db.sql

thank you RFAY!

For some reason the first command gives me that error, maybe because I am on WIN and not LINUX?

bobo
  • 71
  • 9
1

After a lot of research we found a nice solution with the help of rfay:

  • System: Windows 11 (x64).

In our case the error was misleading and it turned out that we had an issue with the pipe command itself. The issue was fixed with an update of WSL2 (the update itself is necessary anyway, as it fixes a big security vulnerability):

  • Go to "Windows Update" → "Advanced Options" → "Receive updates for other Microsoft Products" and turn it on.
  • Search again for (new) updates
  • Install pending updates (you should notice there is a security fix for WSL2)
  • Restart and you should be good to go

(as described in this article)

Our first solution to this was to just import the dump manually:

  • install mysql-client

  • find out the port of the running db-container, e.g. with

    ddev describe

  • import db with the following command:

    mysql -h localhost -P db_container_port -u db -p --default-character-set=utf8 database_name < path:\dir\x.sql

cheers, ggs

ggs
  • 11
  • 2