MySQL in a Docker Container cheat sheet

Here’s a cheat sheet to run MySQL in a Docker container in your Windows or Mac laptop in a few minutes. In this brief how-to you will:

  1. Install Docker Desktop in your laptop
  2. Download official Oracle MySQL image or Docker Inc. image
  3. Start the container
  4. Administer it
  5. Start a MySQL session and start a Linux session

Download and install Docker

You can download Docker Desktop for Windows or Mac from https://docs.docker.com/desktop/. Install like any other application and you’re ready to move to the next step. As you can read from the docs, Docker Desktop will install several things like Docker Compose or Kubernetes. We’ll use both in advanced examples in future posts.

Pull MySQL Server image

Now you can pull the MySQL Server image. You have two options. You can download the image maintained by Oracle MySQL (find the description here https://dev.mysql.com/doc/refman/8.0/en/linux-installation-docker.html)

docker pull mysql/mysql-server:latest

Or you can download the image maintained by Docker Inc. You can find a description together with examples here: https://hub.docker.com/_/mysql

docker pull mysql 

The differences? Oracle MySQL image runs over Oracle Linux, whereas Docker Inc. image runs over Debian. And if you have a MySQL subscription, you will get Support for the Oracle MySQL Docker image if in trouble.

List Docker images

You can list the brand new MySQL image here. Pay attention to the IMAGE ID field, you will need it (I have downloaded both images, Oracle MySQL and Docker Inc. in the following output).

docker images
REPOSITORY           TAG       IMAGE ID       CREATED       SIZE
mysql                latest    5c62e459e087   6 days ago    556MB
mysql/mysql-server   latest    1504607f1ce7   6 weeks ago   391MB

Start a MySQL image in a Docker container

You can start the container, and choose a:

  • A name for the container (mysql_cnt in the example)
  • The root password
  • The image you want to launch
docker run --name=mysql_cnt -e MYSQL_ROOT_PASSWORD="Password1*" --restart on-failure -d 5c62e459e087

Find additional information to configure the instance in the corresponding image documentation, shared before.

Verify that the container has started normally

Make sure the container is up.

docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                 NAMES
30f6e1462b9e   5c62e459e087   "docker-entrypoint.s…"   4 minutes ago   Up 4 minutes   3306/tcp, 33060/tcp   mysql_cnt

Troubleshooting

If the container has not started, you can check logs. In this case, all is working.

docker logs mysql_cnt

[...]
2021-06-28T13:46:43.873232Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.25'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

Start and stop the container

Stop your container:

docker stop mysql_cnt
mysql_cnt

Verify it’s stopped:

docker ps -a         
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS                    PORTS     NAMES
30f6e1462b9e   5c62e459e087   "docker-entrypoint.s…"   5 minutes ago   Exited (0) 1 second ago             mysql_cnt

And restart it:

docker start mysql_cnt
mysql_cnt

Remove the container

As easy as stopping it and running:

docker rm mysql_cnt
mysql_cnt

Get a mysql command line client session

In order to authenticate, you need to have the mysql command line client installed, or even better, MySQL Shell:

docker exec -it mysql_cnt mysql -uroot -p        
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Create a bash session

In case you would like to install things or edit the my.cnf:

docker exec -it mysql_cnt bash           
root@10b5e2727ef3:/# 

Note that if you installed a Debian based release, you will be able to install stuff like:

apt-get update
apt-get install vim

If you installed the Oracle MySQL image, it comes with Oracle Linux installed. Then use:

microdnf update
microdnf install vim

You are now able to setup Docker in your laptop, download your favorite MySQL image, start it in a container and stop it and also capable of installing packages in the Linux distribution. You can configure and optimize MySQL as usual, using SET PERSIST (recommended over editing the configuration file manually, when possible).

If you are curious and would like to explore running MySQL containerized services, you may want to read the official documentation. You will find several hints to use networking or taking backups.

The post MySQL in a Docker Container cheat sheet appeared first on mortensi.

Planet MySQL

Comic for June 27, 2021

https://assets.amuniversal.com/d165c9409a5601395f68005056a9545d

Thank you for voting.

Hmm. Something went wrong. We will take a look as soon as we can.

Dilbert Daily Strip

How Adhesive Bandages are Made

https://theawesomer.com/photos/2021/06/how_bandages_are_made_t.jpg

How Adhesive Bandages are Made

Link

Next time you get a cut and slap a bandage on it, remember this factory video in appreciation of all the engineering and operational complexity that goes into producing that little thing you stuck on your skin. There’s something incredibly satisfying about watching all of those roller machines running.

The Awesomer

Screwing around at Lowes

I went to Lowes for more safety chain for the U-Haul trailer I’m pulling.

It comes with the DOT safety chain in case your hitch fails.

I wanted chain to padlock the trailer to the truck so it’s harder to steal the trailer by disconnecting it from the truck while it’s  parked.

So I ask for two 5-foot lengths of 5/16 trailer chain while holding some heavy duty padlocks.

The Lowes person and I have this conversation.

“What are you trying to secure?”

“I’m not”

“What’s the chain for?”

“Chain fights.”

“What?”

“Chain fights.  Two men enter, one man leaves.  You’ve never beat a man with a padlock on a chain? ”

“Umm….”

“It’s a hell of a rush.”

“Okay….”

“Chain fights.”

I’m gonna get banned from Lowes.

 

 

Calling All Rebels! CMMG Drops Secret Plans to Build Your Own AR Blaster!

https://cdn0.thetruthaboutguns.com/wp-content/uploads/2021/06/build_blaster.jpegCalling All Rebels! CMMG Drops Secret Plans to Build Your Own AR Blaster!

CMMG has brought a piece of cinematic history to life by pulling together the parts and plans to build an AR Blaster in 22LR.

Check out the interactive video below to view all the parts needed to build your own AR Blaster!

 

 

 

 

Continue reading Calling All Rebels! CMMG Drops Secret Plans to Build Your Own AR Blaster! at The Truth About Guns.

The Truth About Guns

Recall Notice: Winchester and Browning 9mm Ammo

https://www.thefirearmblog.com/blog/wp-content/uploads/2021/06/re-180×180.jpg

Certain lots of Winchester and Browning 115gr 9mm ammo have been recalled for safety.When it comes to handling your firearms in any capacity or context, nothing is more important than safety. Everyone should know the basic firearms safety rules inside and out before they ever get on a live-fire range. Beyond those fundamentals like keeping your gun pointed in a safe direction and keeping your finger off of […]

Read More …

The post Recall Notice: Winchester and Browning 9mm Ammo appeared first on The Firearm Blog.

The Firearm Blog

The Mega Pistol: DIY 3D-Printed 40-Round .22LR Semi-Auto Pistol

https://www.thefirearmblog.com/blog/wp-content/uploads/2021/06/megapistol-180×180.jpg

New DIY "Mega Pistol" 3D-Printed and Aluminum Milled 22LR Semi-AutoI was recently bumming around on YouTube when I came across an interesting video from May 26th featuring a supposedly 100% original design of a semi-automatic .22LR pistol. Coming from the YouTube channel Humphrey Wittinsworth IV, the so-called “Mega Pistol” features a 40-round fixed rotary magazine that would only really be possible to the common […]

Read More …

The post The Mega Pistol: DIY 3D-Printed 40-Round .22LR Semi-Auto Pistol appeared first on The Firearm Blog.

The Firearm Blog

New Device Creates Water From Thin Air

https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/b1252a9e16958b923f134c4172466771.jpg

The pilot condenser atop an ETH Zurich building.
Photo: ETH Zurich/Iwan Hächler

As we look towards a Waterworld-esque future where our access to H20 is increasingly rare, it’s even more important to figure out how to squeeze every last drop we can, including out of thin air. In a study published Wednesday in Science Advances, a team of researchers from ETH Zurich demonstrated a new way to create drinking water from humidity using only the sun as power.

There are lots of powerful atmospheric water generators on the market. But they still rely on technologies like fans that need external power. Passive water collection systems, meanwhile, are time-limited: They generally only work at night, when humidity is higher, and the water is in danger of evaporating back into the atmosphere when the sun comes up. There’s been a recent surge in techniques that use trays of materials, like gels, metals, salts, and other compounds to collect water when humidity is high at night; the material is then naturally heated by the sun and releases the water it has collected. The downside of this technique, however, is that it’s not 24/7, and it’s not automatic. The team of researchers wanted to bypass all these systems’ various issues.

“We said, let’s try something that really doesn’t require any energy, so it’s really energy neutral and only limited by physical principles,” said Iwan Hächler, a postdoctoral fellow at ETH Zurich and the lead author of the study. “We thought, ‘what if we show we can evaporate water? What if we try to condense it using radiative heat or radiative energy?’”

The resulting design is deceptively simple–it looks basically like a wide cone placed on top of a box, with a glass pane at the narrow end of the cone on top of the box. Each component here plays a key role.

Condensation happens when water in the air comes in contact with a surface that is below the ambient temperature. To ensure this process happens, researchers coated the glass pane with polymer and silver, allowing it to reflect the sunlight back and keep itself cooler than the ambient temperature. On the underside of the pane is a special coating where moisture from the air can collect and drop without requiring human or mechanical help. The cone acts like a radiation shield, which keeps the device from overheating and deflects the heat energy created from the condensation process.

G/O Media may get a commission

“True condensation creates a tremendous amount of heat, because of the phase change of the water from gaseous to liquid,” said Hächler. “So we designed a radiation shield, which boosted the performance to allow us to get bigger yields.”

The design works pretty well, Hächler said. In lab tests, the maximum yield his team was able to get from the device was 0.05 liters (1.8 fluid ounces) per square meter per hour, very close to the theoretical maximum yield that researchers had calculated. That means the device is able to practically produce around 1.2 liters per square meter per day, or about a third of a person’s required daily intake. This is around twice the output of other passive technologies, the researchers said.

One of the biggest pluses of this system is that it is pretty easy and cheap to set up. Hächler said that the special coating that eliminates the water-wiping action isn’t totally needed to make the system function, while the silver coating on the glass pane would probably work just as well with any super-reflective surface, like chalk or white paint.

“We made a joke that we should make a version with cardboard and aluminum, but we could,” said Gabriel Schnoering, a professor of thermodynamics at ETF Zurich and another coauthor of the study. “Maybe not the same performance, but the idea works with glass, cardboard, aluminum.”

The possibilities for a device that could just sit there and create water for days on end are, pretty big. The climate crisis is causing dry places to become even drier. In other locations, groundwater reserves are being depleted at an unsustainable level. While the system alone couldn’t meet the needs of a region like the entire western U.S., which is currently in a megadrought and facing water restrictions, it could still play a role in helping address shortages there or other parts of the world that are water stressed.

Hächler said the system could be easily coupled with desalination. The air near the surface of the ocean is pretty humid, so desalination systems “could just let [the device] float around” and do its job. And it opens up possibilities for people living in poorer or remote areas without steady power who need more water.

“You could imagine installing it on a roof for families, and they could get some potable water,” he said.

Gizmodo