Setting mysql docker container

116 Views Asked by At

I am trying to create a container for mysql schema. I have a database already and I just wanted to start from within a container this commands: docker run -it -v ~/path/to/myschema:/var/lib/mysql --name mysql-server-remote -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_database=mytestforDocker centurylink/mysql this one creates my schema containerized but when I try to access it via MySQL workbench, even though I see the schema listed, it says "Tables could not be fetched"

my only problem is that if I want to set a different user and password for the same, I get access errors after the container gets created docker run -it -v ~/path/to/myschema:/var/lib/mysql --name mysql-server-remote -p 3306:3306 -e MYSQL_USER=mickey -e MYSQL_PASSWORD=mouse -e MYSQL_database=mytestforDocker centurylink/mysql

this one will result in this error Access denied for user 'mickey'@'172.17.0.1' (using password: YES...

Any ideas will be greatly appreciated.

Basically none of the two ways worked in putting my existing schema into a container, whether be it with root access or with access different credentials created with ALL privileges. Any idea or documentation out there to put my existing schema into a container and have others use it from docker?

1

There are 1 best solutions below

0
On

Well, you have to set the permissions. Look up the "GRANT PRIVILEGES" don't forget to flush ;)