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

  • Run Docker container with preset IP from Ansible
  • Concurrent access to docker.sock on k8s
  • Unable to bring apache2 home page in my browser while configuring nodes by puppet
  • Custom docker image missing from Bluemix
  • `npm start` in docker ends with: Please install a supported C++11 compiler and reinstall the module
  • Docker exec rpc error code =13 desc = invalid header field value “oci runtime error: exec failed: cannot exec a container that has run and stopped\n”
  • 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 lvm thin pool cleanup
  • Check/connect to Redis running within docker from Java(Spring Boot) or Node.js
  • Bind docker container to IP on OSX
  • Docker missing log4net ConsoleAppender logs
  • Transmission WebUI 409 in Docker Container
  • On premise Docker Central
  • 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.