Install Mysql On Docker

  1. Install Mysql On Docker Mac
  2. Install Mysql On Docker Download
  3. Install Mysql On Docker Python

Feb 07, 2021 Tutorial MySQL - Docker Installation on Ubuntu Linux. Install the Docker service. Copy to Clipboard. Apt-get update apt-get install docker.io. Download the MySQL docker image from the online repository. Copy to Clipboard. Docker pull mysql. List the Docker images installed on your system. Copy to Clipboard. Nov 05, 2018 I decide to use Docker image of MySQL. Step, download and install Docker Community Edition for Windows. Step, test Docker does work correctly c: docker run hello-world If Docker running properly go to the next step. Step, download and run mysql container c: docker run –name mysql -p 3306:3306 -e MYSQLROOTPASSWORD=pasw123456 -d. Nov 19, 2019 Connecting to MySQL Server Docker Container. Installing with Docker means you do not get any tools, utilities, or libraries available on your host directly, so you either install these separately, access created instance from a remote host, or use command lines shipped with docker image. To Start MySQL Command Line Client with Docker Run.

I’m a Developer who last 6 years using C#, Asp.Net, SQL Server and Oracle.
And now I’m trying to learn Laravel Php Framework.
Training for Laravel need of using MySQL. I decide to use Docker image of MySQL.

1. step, download and install Docker Community Edition for Windows

2. step, test Docker does work correctly
c:> docker run hello-world
If Docker running properly go to the next step.

3. step, download and run mysql container
c:> docker run –name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pasw123456 -d mysql/mysql-server:latest

Install Mysql On Docker Mac

Install

4. step, try to access to mysql container, learn IP address of the container
List running Docker containers, you will see Container ID, Image, Names, … info
c:> docker ps -a
Running mysql Docker container ID is 9535aa43b64d
Inspect all information about mysql container using this Container ID
c:> docker inspect 9535aa43b64d
You will see “IPAddress”: “172.xx.xx.xx” in my case this is 172.17.0.2
The basic test to access container is using Ping command
c:> ping 172.17.0.2
Reply from 172.17.0.2: Destination host unreachable.
Ping statistics for 172.17.0.2: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss)
Why I can’t access the container?
Because my Windows 10 Host system IP address is 192.168.1.101 Docker mysql container address is 172.17.0.2.
They are on different IP subnets and can’t communicate with each other.
To solve this problem I need to define a new route for my Windows host system.
This route definition will help Windows host to reach to the Docker mysql container.

Install Mysql On Docker Download

5. step, add route definition on Windows 10 to access mysql Docker container
Open Command Prompt as Administrator and run route command
c:> route /P add 172.17.0.0 MASK 255.255.0.0 10.0.75.2
Test again communication between the host and mysql container
c:> ping 172.17.0.2
Reply from 172.17.0.2: bytes=32 time<1ms TTL=63
Finally, we can communicate with the mysql Docker container.

6. step, connect o mysql with Database Workbench tool
I try to connect but got a message, “Can’t connect to MySQL server on ”
The reason for this message is mysql not configured for remote connection.
I can connect only from localhost to mysql.

Install Mysql On Docker Python

7. step, connect to running mysql container and configure mysql for remote connection
Connect to mysql Docker container :
c:> docker exec -it 9535aa43b64d bash
Connect to mysql server :
mysql -u root -p
List user and host access information :
SELECT host, user FROM mysql.user;
Create a mysql user ‘root’ that can connect to mysql from anywhere.
CREATE USER ‘root’@’%’ IDENTIFIED BY ‘pasw123456’;
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ WITH GRANT OPTION;
I now again trying to connect and again I get a different error message.
Error message: ‘Authentication plugin ‘caching_sha2_password’ cannot be loaded’

8. step, change mysql password type to ‘mysql_native_password’
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘pasw123456’;

Finally, I can connect to mysql container and can create a database, tables and views.