Kenny
Kenny

Reputation: 4572

Docker - Can't access MySQL CLI in container

In my MySQL container that I have configured per the official image, it does not allow me to access the CLI from my host machine, nor any other of my containers, despite being linked:

Access denied for user 'root'@'172.17.0.3'

Now, I know that I have not configured external access on my MySQL container, but how can I configure it if I can't even access the CLI to grant myself permissions? Could I create a Dockerfile and change some system settings before the initial installation of MySQL? If so, how would I go about doing that?

My fig.yml file, which is used to set up my MySQL container:

mysql:
  image: mysql:latest
  volumes:
    - .:/mydir
  working_dir: /mydir
  ports:
    - "3306:3306"
  environment:
    - MYSQL_DATABASE=mydb
    - MYSQL_ROOT_PASSWORD=mypass

Upvotes: 1

Views: 1476

Answers (2)

Andreas Wederbrand
Andreas Wederbrand

Reputation: 40041

You can try to set the environment variable MYSQL_PWD with the password for root. It's the official environment variable for the client.

http://dev.mysql.com/doc/refman/5.6/en/password-security-user.html

Upvotes: -1

user2105103
user2105103

Reputation: 13115

The answer is in your screenshot. (using password: NO). Add a -p to your mysql command line.

Upvotes: 2

Related Questions