How to access MySQL deployed on Docker?

To access MySQL deployed in Docker, you can follow these steps:

  1. Start MySQL container: Use the following command to start MySQL container in Docker:
  2. Run a Docker container named “mysql” with the latest version of MySQL using your desired password for the root user, mapping port 3306 on the host to port 3306 in the container, in detached mode.
  3. This will run a MySQL container in the background and map the host’s port 3306 to the container’s port 3306.
  4. Connect to the MySQL container: Use the following command to connect to the MySQL container:
  5. Run a bash shell inside the mysql container using docker exec command.
  6. Accessing MySQL: Once you are connected to the command line interface of the MySQL container, use the following command to access MySQL:
  7. Login to MySQL as the root user with a password.
  8. Next, enter the password you set in Step 1.

Now, you can use the MySQL command-line interface to perform database operations.

广告
Closing in 10 seconds
bannerAds