how to load dump on docker mysql container based on centos6?

I am trying to create my own mysql docker container based on official centos6 image. I am successful in building and running mysql container. However, i would like to have dump loaded when container starts. Now this is generating error:

“ERROR 1045 (28000): Access denied for user ”@’localhost’ “

  • npm ERR! Failed when make ionic serve command (ask for checking version of node.js and npm installed)
  • Docker Consul service ip advertised as internal docker ip
  • Docker volume option create folder as “root” user
  • Docker nginx proxy to host
  • Docker: Is it necessary to mount a new partition
  • Error when start a container
  • Please help.

    I have following configuration loading when building image:

    #!/bin/bash
    
    # Borrowed from https://github.com/docker-library/docker-mysql
    
    set -e
    
    if [ -z "$(ls -A /var/lib/mysql)" -a -n "$MYSQL_ROOT_PASSWORD" ]; then
            if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
                    echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
                    echo >&2 '  Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
                    exit 1
            fi
    
            scl enable mysql55 "mysql_install_db --user=mysql --datadir=/var/lib/mysql"
    
            # These statements _must_ be on individual lines, and _must_ end with
            # semicolons (no line breaks or comments are permitted).
            # TODO proper SQL escaping on dat root password D:
            cat > /tmp/mysql-first-time.sql <<-EOSQL
                    DELETE FROM mysql.user ;
                    CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
                    GRANT ALL PRIVILEGES  ON *.* TO 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
                    CREATE USER 'mysql'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
                    GRANT ALL PRIVILEGES  ON *.* TO 'mysql'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
                    CREATE USER ''@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
                    GRANT ALL ON *.* TO ''@'%' IDENTIFIED BY IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
                    DROP DATABASE IF EXISTS test ;
                    commit;
                    FLUSH PRIVILEGES ;
            EOSQL
    
            scl enable mysql55 "mysqld_safe --init-file=/tmp/mysql-first-time.sql &"
            sleep 5
            exec scl enable mysql55 "mysqladmin -uroot -p${MYSQL_ROOT_PASSWORD} shutdown"
    fi
    
    chown -R mysql:mysql /var/lib/mysql
    exec scl enable mysql55 "mysqld_safe --datadir=/var/lib/mysql --user=mysql"
    

  • Docker local registry : push fails
  • Setting Dynamic Env variable in Docker
  • How long should I wait when I run `docker-compose up`? What should I do to retry?
  • Docker swarm with Glassfish 3.1.2.2 image fails to start nodes
  • Connecting to SQL Server Express from within Docker Container gives an error occurred evaluating the password
  • Need to move docker from one mac to another mac
  • One Solution collect form web for “how to load dump on docker mysql container based on centos6?”

    It looks like you’re trying to create an unnamed user in these lines:


    CREATE USER ''@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
    GRANT ALL ON *.* TO ''@'%' IDENTIFIED BY IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;

    I don’t know if that’s valid in your SQL engine, but I don’t think it is legal in MySQL.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.