skip to Main Content

On my centos host, running mysql command through docker exec is hung forever:

$ docker exec mysql /usr/bin/mysql -u root --password=passwd123 < mysql.backup.sql

The mysql DB is accessible using mysqlworkbench just fine.

Thanks for your help.

2

Answers


  1. Chosen as BEST ANSWER

    I was missing -i parameter in my original command.

    This command works perfectly:

    $ $ docker exec -i mysql /usr/bin/mysql -u root --password=passwd123 < mysql.backup.sql
    

  2. You can try following for backup

    docker exec mysql /usr/bin/mysqldump -u root --password=passwd123 DATABASE > backup.sql

    Instead of mysql you should use mysqldump ( Mysqldump is a command-line utility that is used to generate the logical backup of the MySQL database. )

    If your purpose is restore, then

    cat backup.sql | docker exec -i mysql /usr/bin/mysql -u root --password=passwd123 DATABASE

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search