Skip to content

mysql:5.5 Can't connect to local MySQL server through socket '/tmp/mysql.sock' #247

Closed
@hxzqlh

Description

@hxzqlh

I once pull mysql:5.5(5.5.53) to my docker image repository, before mysql:5.5 updating to 5.5.54, the Dockerfile keep unchanged like this:

FROM mysql:5.5
ENV MYSQL_ROOT_PASSWORD 123
ENV MYSQL_USER vdna
ENV MYSQL_PASSWORD 123
USER root
COPY init_db.sh /docker-entrypoint-initdb.d/init_db.sh

init_db.sh:

#!/bin/sh

mysql -uroot -p$MYSQL_ROOT_PASSWORD -e "grant all privileges on *.* to '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';"
mysql -uroot -p$MYSQL_ROOT_PASSWORD -e "flush privileges;"

build the Dockerfile to image:

docker build -t hxzqlh/mysql_db .

when run the container:docker run -it --rm hxzqlh/mysql_db, 5.5.54 version cannot start container , from the console output, problem occured during executing the init_db.sh.

Initializing database
161229  2:41:05 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
161229  2:41:05 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.54) starting as process 67 ...
161229  2:41:05 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
161229  2:41:05 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.54) starting as process 73 ...

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h  password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

Database initialized
161229  2:41:05 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
161229  2:41:05 [Note] mysqld (mysqld 5.5.54) starting as process 77 ...
MySQL init process in progress...
161229  2:41:05 [Note] Plugin 'FEDERATED' is disabled.
161229  2:41:05 InnoDB: The InnoDB memory heap is disabled
161229  2:41:05 InnoDB: Mutexes and rw_locks use GCC atomic builtins
161229  2:41:05 InnoDB: Compressed tables use zlib 1.2.3
161229  2:41:05 InnoDB: Using Linux native AIO
161229  2:41:06 InnoDB: Initializing buffer pool, size = 128.0M
161229  2:41:06 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
161229  2:41:06  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
161229  2:41:06  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
161229  2:41:06  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
161229  2:41:06  InnoDB: Waiting for the background threads to start
MySQL init process in progress...
161229  2:41:07 InnoDB: 5.5.54 started; log sequence number 0
161229  2:41:07 [Warning] 'user' entry 'root@a80d37efe4de' ignored in --skip-name-resolve mode.
161229  2:41:07 [Warning] 'user' entry '@a80d37efe4de' ignored in --skip-name-resolve mode.
161229  2:41:07 [Warning] 'proxies_priv' entry '@ root@a80d37efe4de' ignored in --skip-name-resolve mode.
161229  2:41:07 [Note] Event Scheduler: Loaded 0 events
161229  2:41:07 [Note] mysqld: ready for connections.
Version: '5.5.54'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
161229  2:41:10 [Warning] 'proxies_priv' entry '@ root@a80d37efe4de' ignored in --skip-name-resolve mode.
161229  2:41:10 [Warning] 'proxies_priv' entry '@ root@a80d37efe4de' ignored in --skip-name-resolve mode.

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init_db.sh
mysql -uroot -p123 -e 'grant all privileges on *.* to '\''vdna'\''@'\''%'\'' identified by '\''123'\'';'
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

while, 5.5.53 version can run successfully.

What changes cause this problem? or , is my init_db.sh wrong?

my docker version:

Docker version 1.12.3, build 6b644ec

os: Mac OS X 10.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions