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’ “

  • Why Docker on Virtualbox can't find my DockerFile?
  • How to Install Hadoop slaves in docker make a master node on local computer to handle these slave nodes?
  • Building Play App as Docker image, remapping port
  • Docker-compose: flag -p equivalence
  • Copy files to docker image after build
  • how to do network isolation among different applications in kubernetes or in docker cluster?
  • 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"
    

  • git ssh can't access to gitlab in a docker container
  • Octohost with knife solo on bare metal? (UserError: Vagrant not installed)
  • how can I change docker storage driver to devicemapper on mac
  • Docker image for windows with oracle12
  • docker_compose v2 volume container
  • Restore database state after integration test using Docker?
  • 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.