Skip to content

Instantly share code, notes, and snippets.

@ratpik
Created January 27, 2022 10:30
Show Gist options
  • Save ratpik/7e4b2ec830c4e924dda4dc376393e1a5 to your computer and use it in GitHub Desktop.
Save ratpik/7e4b2ec830c4e924dda4dc376393e1a5 to your computer and use it in GitHub Desktop.
Re-installing MySQL 5.7 Mac OSX
#List all instances of MySQL that exists by running
brew services
# Remove each instance by running
brew uninstall <instance_name>
#Delete the MySQL directory in /usr/local/var/mysql:
rm -rf /usr/local/var/mysql
# Might need to run brew update here if brew has not been updated for a while
#Reinstall MySQL using Homebrew:
brew install [email protected]
#Rerun mysql.server start:
mysql.server start
#Check the user who has permissions (do not run with sudo)
cd /usr/local/var/mysql
ls -lrt
total 387176
-rw-r----- 1 pmandrek admin 48M Jan 27 15:37 ib_logfile1
-rw-r----- 1 pmandrek admin 56B Jan 27 15:37 auto.cnf
-rw------- 1 pmandrek admin 1.6K Jan 27 15:37 ca-key.pem
-rw-r--r-- 1 pmandrek admin 1.1K Jan 27 15:37 ca.pem
-rw------- 1 pmandrek admin 1.6K Jan 27 15:37 server-key.pem
-rw-r--r-- 1 pmandrek admin 1.1K Jan 27 15:37 server-cert.pem
-rw------- 1 pmandrek admin 1.6K Jan 27 15:37 client-key.pem
-rw-r--r-- 1 pmandrek admin 1.1K Jan 27 15:37 client-cert.pem
-rw------- 1 pmandrek admin 1.6K Jan 27 15:37 private_key.pem
-rw-r--r-- 1 pmandrek admin 452B Jan 27 15:37 public_key.pem
drwxr-x--- 90 pmandrek admin 2.8K Jan 27 15:37 performance_schema
drwxr-x--- 77 pmandrek admin 2.4K Jan 27 15:37 mysql
drwxr-x--- 108 pmandrek admin 3.4K Jan 27 15:37 sys
-rw-r----- 1 pmandrek admin 436B Jan 27 15:37 ib_buffer_pool
-rw-r----- 1 pmandrek admin 6B Jan 27 15:37 MacBook-Pro.local.pid
-rw-r----- 1 pmandrek admin 4.3K Jan 27 15:41 MacBook-Pro.local.err
drwxr-x--- 113 pmandrek admin 3.5K Jan 27 15:41 postman_sync
drwxr-x--- 17 pmandrek admin 544B Jan 27 15:42 postman_sync_history
drwxr-x--- 9 pmandrek admin 288B Jan 27 15:42 integration_service
-rw-r----- 1 pmandrek admin 12M Jan 27 15:43 ibtmp1
-rw-r----- 1 pmandrek admin 76M Jan 27 15:43 ibdata1
-rw-r----- 1 pmandrek admin 48M Jan 27 15:43 ib_logfile0
#Create local data directory for persistent data
mkdir -p ~/data/mysql_data/5.7
#Local development network
docker network create dev-network
#Run MySQL
docker run --restart always --name mysql5.7 --net dev-network -v /Users/pmandrek/data/mysql_data/5.7:/var/lib/mysql -p 3306:3306 -d -e MYSQL_ROOT_PASSWORD= mysql:5.7
#Connect to MySQL
docker exec -it mysql5.7 mysql -uroot -p
#Change root password
ALTER USER 'root'@'localhost' IDENTIFIED BY '';
#Reference
#https://medium.com/@crmcmullen/how-to-run-mysql-in-a-docker-container-on-macos-with-persistent-local-data-58b89aec496a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment