notes/mysql_docker_pip_setup.md
2026-03-23 11:16:05 -07:00

1.6 KiB

Setup

Considering that it's been a while since I've set up MySQL and Pip, I thought I'd document some of the basics here again for my own sake:

Setting Up Mysql

I opted to setup mysql via docker instead of installing it on bare metal. Simply use the contained docker-compose.yml file with docker-compose to get a very basic mysql instance up and running:

docker-compose up -d

Confirm it's running using ps:

docker ps

As long as it's up and running you can test it to be sure:

docker exec -it myjsql-basic mysql -u root -p

And put in the default root password from the docker-compose.yml file.

Virtual Environments

You'll want to install pip and also get a virtual environment running:

python -m venv .venv
source .venv/bin/activate

Once inside the virtual environment, upgrade the local pip:

python -m pip install --upgrade pip

And use that pip to install all the packages from requirements.txt:

python -m pip install -r requirements.txt

If you need to create a new requirements.txt, then just:

pip freeze > requirements.txt

Confirming MySQL Statements Were Executed:

From within the docker exec'ed mysql repl, for now just use SHOW DATABASES to ensure it went through:

mysql> SHOW DATABASES;

You should see output like this:

+--------------------+
| Database           |
+--------------------+
| employee_db        |
| information_schema |
| myapp              |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.001 sec)