Saturday, May 29, 2021

Mysql Installation in 3 Steps For Mac/Apple

Pre-Requisite

Add the below paths to "/etc/paths"

/usr/local/mysql/bin

/usr/local/mysql/support-files

Step 1

Using any SQL clients install the MySql in your Mac

Command for Brew

brew install mysql

Error 

If brew installation failing, try reinstalling the mysql.
brew reinstall mysql    

If its still not working, execute below commands to remove all the folders and run the brew install command again.

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

Step 2 

Initialise mysql client using the below command which will create all the necessary data folders.
mysqld --initialize

If mysqld command not found is returned, add the below paths

    vi /etc/paths

Add the below paths to it

/usr/local/mysql/bin

/usr/local/mysql/support-files


 

Error

!!!! Do not create "data" folder under /usr/local/mysql* !!!!

The mysql "--initialize" command will take care of it. Delete the data folder if its created by you.

"The designated data directory /usr/local/mysql-8.0.25-macos11-x86_64/data/ is unusable. You can remove all files that the server added to it."


Step 3

Start the mysql server

    mysql.server start



If you still face issues try uninstalling mysql and follow from all the Steps.