Skip to content

Instantly share code, notes, and snippets.

@rajibbinalam
Created August 15, 2024 05:33
Show Gist options
  • Save rajibbinalam/8293dd79cf73f977cf2dc373420b38a6 to your computer and use it in GitHub Desktop.
Save rajibbinalam/8293dd79cf73f977cf2dc373420b38a6 to your computer and use it in GitHub Desktop.
Backup Databaes if MySql Error on MACBOOK => Resolve

Sometimes PHP or MySql having isssue or Errors, And then if web reinstall mysql all of old databaes will banish

Backup Before reinstall MySql

Step-1: goto /usr/local/var/mysql

using Terminal:

cd /usr/local/var/mysql
open .

Then Make a backup file of the databases. following below

Stop MySQL Service:

sudo brew services stop mysql

Backup Current Data Directory:

sudo mv /usr/local/var/mysql /usr/local/var/mysql_backup

Then install/ reinstall mysql as well

Move/copy/replace old database directories

sudo cp -R /path/to/old/data/directory /usr/local/var/mysql

Fix ownership and permissions

sudo chown -R _mysql:_mysql /usr/local/var/mysql

Start mysql

sudo brew services start mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment