Skip to content

Instantly share code, notes, and snippets.

@kaanra
Last active October 5, 2022 23:57
Show Gist options
  • Save kaanra/8971281c64ef41b30fe4b3e3fb272ed2 to your computer and use it in GitHub Desktop.
Save kaanra/8971281c64ef41b30fe4b3e3fb272ed2 to your computer and use it in GitHub Desktop.
[Homebrew mysql] #terminal #homebrew #mysql

brew install [email protected] https://laravel.com/docs/6.x/valet#installation

brew services restart [email protected]
brew services start [email protected]
brew services stop [email protected]

List running services

brew services list

Create symlink

brew link [email protected] --force

https://stackoverflow.com/questions/33268389/what-does-brew-link-do

Creates symlinks to installations you performed manually in Cellar. This allows you to have the flexibility to install things on your own but still have those participate as dependencies in homebrew formulas.

Remove symlink

brew unlink [email protected]


Dropbox Syncing

Database is at:

/usr/local/var/mysql

Symlink to Dropbox

ln -s "/my-dropbox/path/mysql" "/usr/local/var/mysql"


Fix -bash: mysql: command not found

After running brew install [email protected] this error appeared.

Create symlink

brew link [email protected] --force

$ brew link [email protected] --force
Linking /opt/homebrew/Cellar/[email protected]/5.7.39... 87 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

Log into mysql

mysql -u root -p

List databases

show databases;


Find where databases are stored in Mac

mysql
SELECT @@datadir, @@innodb_data_home_dir

Something happened kill it all and reset

https://stackoverflow.com/questions/9695362/macosx-homebrew-mysql-root-password

$ brew services stop mysql
$ pkill mysqld
$ rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!!
$ brew postinstall mysql
$ brew services restart mysql
$ mysql -uroot

Kill it all round 2 cause last answer didn't work

https://stackoverflow.com/questions/15016376/cant-connect-to-local-mysql-server-through-socket-homebrew

brew services stop [email protected]
brew uninstall [email protected]
pkill mysqld
rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!
rm -rf /usr/local/var/mysql
rm /usr/local/etc/my.cnf

brew install [email protected]
brew link --force [email protected]
brew services restart [email protected]

brew link [email protected] --force
mysql -u root -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment