Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Creating a MySQL 5.7 Docker Container
- ### Prerequesites:
- - Docker installed
- ### Steps
- 1. Pull the 5.7 MySQL image down:
- `docker pull mysql/mysql-server:5.7`
- 2. Create a new container using the image above, giving it a recognizable local name:
- `docker run --name=NewMySQLContainer -d mysql/mysql-server:5.7`
- 3. Your container should be up and running, which means you have a MySQL server running
- Now we need to change the `root` user's password, as one was auto-created for you.
- First, we must find out what the auto-created password was, then use it to login.
- Look at the logs for your container using the recognizable local name you gave it:
- `docker logs NewMySQLContainer`
- Look for a line that looks like this, and copy the value listed:
- `[Entrypoint] GENERATED ROOT PASSWORD: _____________________`
- 4. Now, we need to ask for Docker's help to give us an interactive terminal to log in to MySQL, using the `exec` method:
- `docker exec -it NewMySQLContainer mysql -u root -p`
- It will then prompt for the password - paste the value you copied from the last step.
- 5. Now we need to perform the first of two actions: first, set the `root` user password to a new value that you can remember (or SKIP this step if you prefer the auto-generated value. Not a bad option imo):
- `ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPassword';`
- Voila, you have a MySQL server running in a Docker container. Spiffy.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement