Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 8 as default, but as we're aiming to get 5.7, we'll need to append @5.7 to the default package key:

  • Enter the following command : $ brew info mysql@5.7
  • Expected output: mysql@5.7: stable 5.7.22 (bottled) [keg-only]

To install MySQL enter : $ brew install mysql@5.7

Additional configuration

Homebrew

  • Install brew services first : $ brew tap homebrew/services

  • Load and start the MySQL service : $ brew services start mysql@5.7.
    Expected output : Successfully started mysql (label: homebrew.mxcl.mysql)

  • Check of the MySQL service has been loaded : $ brew services list 1

  • Force link 5.7 version - $ brew link mysql@5.7 --force

  • Verify the installed MySQL instance : $ mysql -V.
    Expected output : Ver 14.14 Distrib 5.7.22, for osx10.13 (x86_64)

MySQL

Open Terminal and execute the following command to set the root password:
mysqladmin -u root password 'yourpassword'

Important : Use the single ‘quotes’ to surround the password and make sure to select a strong password!

Database Management

To manage your databases, I recommend using Sequel Pro, a MySQL management tool designed for macOS.
Current version available: 1.1.2

Comments

1 The brew services start mysql@5.7 - instruction is equal to :

$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
@ricketybridge

This comment has been minimized.

Copy link

@ricketybridge ricketybridge commented Jul 18, 2018

After following these instructions, the mysql command results in the following error:

ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql@5.7/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found
@stevenchanin

This comment has been minimized.

Copy link

@stevenchanin stevenchanin commented Aug 18, 2018

This worked great for me on a clean install of OS X 10.13.6

@rebz

This comment has been minimized.

Copy link

@rebz rebz commented Sep 1, 2018

Similar to @ricketybridge I also receive ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

@AtulKhanduri

This comment has been minimized.

Copy link

@AtulKhanduri AtulKhanduri commented Sep 2, 2018

@rebz I'm also getting the same error.

@ashish-shrma

This comment has been minimized.

Copy link

@ashish-shrma ashish-shrma commented Sep 3, 2018

@rebz @atul did you guys find a solution?

@greggles

This comment has been minimized.

Copy link

@greggles greggles commented Sep 11, 2018

I had the same error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) after following these instructions. I then found this set of steps to fully remove mysql and I did those steps to remove. Then I followed the steps in this gist and they worked fine. So...good luck :) @rebz @atul25khanduri @ashish-shrma also ping @operatino in case you want to update your gist to include some ideas about fully removing mysql first.

Edited to add: Coming back to this in April of 2019 and I had to also run mysqld --initialize

@Paveltarno

This comment has been minimized.

Copy link

@Paveltarno Paveltarno commented Sep 17, 2018

@greggles Thanks a lot! Worked like a charm

@kezzico

This comment has been minimized.

Copy link

@kezzico kezzico commented Oct 3, 2018

Still seeing the "Can't connect to local MySQL server..."

Tried Greggle's link to fully remove a previous install of MySQL 8, but after a restart the problem persists

# brew services start mysql@5.7
==> Successfully started `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)

# launchctl list | grep mysql
-	0	homebrew.mxcl.mysql@5.7

Brew services is reporting the service started, but Launchctl is not showing a PID.

Here is the log output

lee@kezzico:~# tail /usr/local/var/mysql/kezzico.local.err 
2018-10-03T21:57:10.986146Z 0 [ERROR] Can't start server: can't check PID filepath: No such file or directory
2018-10-03T21:57:11.6NZ mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Finally got the service to start by creating a folder for the PID, and setting the permission on the folder to global read/write/x.

# sudo mkdir /var/run/mysqld
# chmod 777 /var/run/mysqld

Not sure why this is necessary. There may be security implications to this. Hopefully someone has a better solution.

@jcartw89

This comment has been minimized.

Copy link

@jcartw89 jcartw89 commented Dec 2, 2018

I had to run mysqld --initialize in order to eliminate the ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) issue. Make sure your /usr/local/var/mysql directory is empty first though.

@ntwobike

This comment has been minimized.

Copy link

@ntwobike ntwobike commented Dec 11, 2018

Got the same issue ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' followed @greggles instructions, it works! mysql version 8.0.12

@sircEUNHO

This comment has been minimized.

Copy link

@sircEUNHO sircEUNHO commented Jan 8, 2019

@greggles you are my savior, haha

@n4ss1m

This comment has been minimized.

Copy link

@n4ss1m n4ss1m commented Jan 28, 2019

I got the following error :
mysqladmin: unable to change password; error: 'The ACL operation failed due to the following error from SE: errcode 190 - Operation not allowed when innodb_forced_recovery > 0'

Google didn't help well : (

@rowild

This comment has been minimized.

Copy link

@rowild rowild commented Feb 21, 2019

How can I use mysqlsh in order to work with documents (nosql)?

@joeljpa

This comment has been minimized.

Copy link

@joeljpa joeljpa commented Mar 12, 2019

had the same issue which @greggles solved. This medium article was simple enough to solve it for me without going to different links.

@JSilversun

This comment has been minimized.

Copy link

@JSilversun JSilversun commented Mar 13, 2019

Thanks @joeljpa that article helped me

@fernyherrera

This comment has been minimized.

Copy link

@fernyherrera fernyherrera commented Mar 26, 2019

Thank you, worked!

@derkhadim

This comment has been minimized.

Copy link

@derkhadim derkhadim commented Apr 1, 2019

Thank you, that work for me

@Heybluguy

This comment has been minimized.

Copy link

@Heybluguy Heybluguy commented Apr 8, 2019

Nice! Before doing this I had 16 errors, now I'm down to 1 when I bundle. In a better spot than I was before. Here is my current error.
"mysql.c:1320:74: error: use of undeclared identifier 'rb_cFixnum'
else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger || argv[i] == rb_cFixnum)"
^

@jamesfacts

This comment has been minimized.

Copy link

@jamesfacts jamesfacts commented Apr 26, 2019

I ran into a weird issue trying to connect to mysql@5.7 after installing with Homebrew. Similar to @kezzico, brew told me that the service was running but it had no PID. When I ran mysqld --initialize, I saw the message [ERROR] --initialize specified but the data directory has files in it. Aborting..

I think this error was caused by a previous install of mysql through MAMP. I followed this answer on SE. After running rm -rf /usr/local/var/mysql, I uninstalled and reinstalled mysql@5.7 and now when I check active services I do see a mysql PID:

 ~  launchctl list | grep mysql
54246	0	homebrew.mxcl.mysql@5.7
@dilip-k-m

This comment has been minimized.

Copy link

@dilip-k-m dilip-k-m commented May 16, 2019

mysqld stop
mysql.server start

@dschreck

This comment has been minimized.

Copy link

@dschreck dschreck commented Jun 15, 2019

I ran into a weird issue trying to connect to mysql@5.7 after installing with Homebrew. Similar to @kezzico, brew told me that the service was running but it had no PID. When I ran mysqld --initialize, I saw the message [ERROR] --initialize specified but the data directory has files in it. Aborting..

I think this error was caused by a previous install of mysql through MAMP. I followed this answer on SE. After running rm -rf /usr/local/var/mysql, I uninstalled and reinstalled mysql@5.7 and now when I check active services I do see a mysql PID:

 ~  launchctl list | grep mysql
54246	0	homebrew.mxcl.mysql@5.7

This works.

@ringate

This comment has been minimized.

Copy link

@ringate ringate commented Jun 21, 2019

No idea why missed add the mysql path. I added by self.

$ mysql -V
-bash: mysql: command not found
$ echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ mysql -V
mysql  Ver 14.14 Distrib 5.7.26, for osx10.14 (x86_64) using  EditLine wrapper
@filmo

This comment has been minimized.

Copy link

@filmo filmo commented Jun 27, 2019

In addition to the other fixes above, I also had to remove

/etc/my.cnf

Before I could get it to do the post install initialization.

@rsalimian

This comment has been minimized.

Copy link

@rsalimian rsalimian commented Aug 13, 2019

to fix the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

I had to also run:
sudo chown -R _mysql:mysql /usr/local/var/mysql

@Leo7654

This comment has been minimized.

Copy link

@Leo7654 Leo7654 commented Sep 18, 2019

brew unlink mysql
brew link mysql@5.7 --force
mysql -V

@aneudysamparo

This comment has been minimized.

Copy link

@aneudysamparo aneudysamparo commented Sep 24, 2019

Hey! Te Amo <3

@JavierPons

This comment has been minimized.

Copy link

@JavierPons JavierPons commented Oct 4, 2019

Works fine, no error. Perfect. Thnx!

@Adrian-Sanchez

This comment has been minimized.

Copy link

@Adrian-Sanchez Adrian-Sanchez commented Oct 10, 2019

For those that are still looking for a solution...this worked for me. I'd appreciate an upvote if it works.
Error relating to: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

https://stackoverflow.com/a/58315841/2209519

@nstanard

This comment has been minimized.

Copy link

@nstanard nstanard commented Oct 17, 2019

Is there any way to get mysql to start on system startup installing via this approach?

@ChildishBob

This comment has been minimized.

@gieart87

This comment has been minimized.

Copy link

@gieart87 gieart87 commented Nov 3, 2019

mysql.server start

Thanks!

@huangyisan

This comment has been minimized.

Copy link

@huangyisan huangyisan commented Dec 1, 2019

I had to run mysqld --initialize in order to eliminate the ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) issue. Make sure your /usr/local/var/mysql directory is empty first though.

thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!

@Catalin-Ionut

This comment has been minimized.

Copy link

@Catalin-Ionut Catalin-Ionut commented Dec 28, 2019

Every step works great and as intended on OSX Catalina.

@filmo

This comment has been minimized.

Copy link

@filmo filmo commented Jan 15, 2020

So I can get it running on the server and connect as local host. (in my case 192.168.5.3)

However when I connect from a remote machine on the same LAN it doesn't seem like port 3306 is accepting connections anymore.

mysql -p -u my_user_name -h -192.168.5.3

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.5.3' (61)

I test with telnet and it also fails to connect.

$telnet 192.168.5.3 3306
Trying 192.168.5.3...
telnet: connect to address 192.168.5.3: Connection refused
telnet: Unable to connect to remote host

On the server (192.168.5.3), I can connect and interact with the databases as I normally would. I've not changed any firewall permissions, so they should be the same as they previously were, which allowed 3306 and worked with 5.6

When I roll the server back to 5.6 via a restore, both telnet and mysql are able to connect (as they had previously before)??

I've tried putting a my.cnf file in /etc/my.cnf and setting the bind-address to each of the following with no luck either.

127.0.0.1
192.168.5.3
0.0.0.0

Any thoughts on why mysql@5.7 wouldn't allow connections from the LAN ?? (seems like it's not listening on 3306 rather than a database password error because even telnet can't reach the port, whereas it could previously.)

@Adrian-Sanchez

This comment has been minimized.

Copy link

@Adrian-Sanchez Adrian-Sanchez commented Jan 15, 2020

@filmo
for me, my cnf file is in /usr/local/etc/my.cnf

@Adrian-Sanchez

This comment has been minimized.

Copy link

@Adrian-Sanchez Adrian-Sanchez commented Jan 15, 2020

If that didnt work, the next step is user privaledges for remote access
CREATE USER ‘USERNAME‘@’REMOTE_IP‘ IDENTIFIED BY ‘PASSWORD‘;
CREATE DATABASE ‘EXAMPLE‘;
GRANT ALL ON EXAMPLE.* TO ‘USERNAME‘@’REMOTE_IP‘;
FLUSH PRIVILEGES;

@omerwwazap

This comment has been minimized.

Copy link

@omerwwazap omerwwazap commented Feb 7, 2020

Thank you, worked as intended on OSX Catalina.

@ZEdgars

This comment has been minimized.

Copy link

@ZEdgars ZEdgars commented Feb 28, 2020

Thanks for this post!!!! It solved by sql schema error and after some days of struggling, I was able to connect Laravel with SQL/SequelPro and migrate databases.

@michaelklopf

This comment has been minimized.

Copy link

@michaelklopf michaelklopf commented Mar 11, 2020

We had the ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) issue too when accessing the db with Sequel Pro and we solved it by adding user=root (which is our standard user we use in Sequel Pro) to the my.cnf file under the bind-address.

# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
user=root
@ewhicher

This comment has been minimized.

Copy link

@ewhicher ewhicher commented Mar 19, 2020

This and @greggles suggestion saved my day, thanks!

@rsalimian

This comment has been minimized.

Copy link

@rsalimian rsalimian commented May 11, 2020

this is what I did to fix: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

  • uninstalled MySQL
  • when you run $ brew install mysql@5.7 make sure it installs with no Error/Warning
  • I got error Warning: The post-install step did not complete successfully
    to fix the error I create /usr/local/var/mysql manually:
  • $ mkdir /usr/local/var/mysql
  • $ chmod 777 mkdir /usr/local/var/mysql
    and then
  • $ brew postinstall mysql@5.7
    and then just follow up rest of instruction to start the MySQL service.
@lesiba7

This comment has been minimized.

Copy link

@lesiba7 lesiba7 commented Jul 18, 2020

Worked for me. Thanks

@shubham-bibliu

This comment has been minimized.

Copy link

@shubham-bibliu shubham-bibliu commented Aug 3, 2020

If still someone facing the issue.

This fixed for me, Mac OS Catalina 10.15.6
https://xuri.me/2015/11/28/troubleshooting-homebrew-mysql-on-os-x.html

@aka47

This comment has been minimized.

Copy link

@aka47 aka47 commented Sep 2, 2020

I did run

rm -rf /usr/local/var/mysql
brew postinstall mysql@5.7

got this error
0 [ERROR] unknown variable 'mysqlx-bind-address=127.0.0.1'

and removed the line with mysqlx-bind-address in /usr/local/etc/my.cnf and run

rm -rf /usr/local/var/mysql
brew postinstall mysql@5.7
@gamesover

This comment has been minimized.

Copy link

@gamesover gamesover commented Sep 9, 2020

in mac, you can run

locate my.cnf
# please remove all my.cnf found in above step
rm -rf /usr/local/var/mysql
mysqld --initialize-insecure
mysql -u root

it works for me

@michaelbrinkworth

This comment has been minimized.

Copy link

@michaelbrinkworth michaelbrinkworth commented Sep 15, 2020

i keep running into a password error for root ,

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

@akshaydk

This comment has been minimized.

Copy link

@akshaydk akshaydk commented Sep 16, 2020

i keep running into a password error for root ,

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

@michaelbrinkworth
Try running mysql -uroot -p.
You will receive a prompt for password.

@efz00

This comment has been minimized.

Copy link

@efz00 efz00 commented Oct 20, 2020

Thanks!

@maghajan

This comment has been minimized.

Copy link

@maghajan maghajan commented Oct 21, 2020

had the same issue which @greggles solved. This medium article was simple enough to solve it for me without going to different links.

Thank you, this helped me fix the issue ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

@Geek92

This comment has been minimized.

Copy link

@Geek92 Geek92 commented Nov 4, 2020

thanks man it works perfectly

@younjiwoo

This comment has been minimized.

Copy link

@younjiwoo younjiwoo commented Nov 10, 2020

No idea why missed add the mysql path. I added by self.

$ mysql -V
-bash: mysql: command not found
$ echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ mysql -V
mysql  Ver 14.14 Distrib 5.7.26, for osx10.14 (x86_64) using  EditLine wrapper

Thank you! ❤️

@wxianfeng

This comment has been minimized.

Copy link

@wxianfeng wxianfeng commented Nov 12, 2020

Great! Thx

@ricarhincapie

This comment has been minimized.

Copy link

@ricarhincapie ricarhincapie commented Nov 25, 2020

After following these instructions, the mysql command results in the following error:

ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql@5.7/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found

Authentication protocols changed from 5.7 to 8 versions of MySQL. Please refer to the link, it may help.
https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server?rq=1

@Byronium

This comment has been minimized.

Copy link

@Byronium Byronium commented Dec 14, 2020

@michaelbrinkworth @akshaydk you can also follow the steps here to either remove the root password or auto log-in with it to avoid having to run mysql -u root -p each time: https://medium.com/@benmorel/remove-the-mysql-root-password-ba3fcbe29870 (I did the latter since it was simpler and more secure).

@Byronium

This comment has been minimized.

Copy link

@Byronium Byronium commented Dec 14, 2020

As mentioned by other users above, this gist is missing a few important steps:

  1. Adding the mysql directory to PATH after installation in order to run mysql command: https://gist.github.com/operatino/392614486ce4421063b9dece4dfe6c21#gistcomment-2950061
  2. Either removing the root password or making a my.cnf file to automatically log in: https://medium.com/@benmorel/remove-the-mysql-root-password-ba3fcbe29870

Since version 5.7, MySQL is secure-by-default:

  • a random root password is generated upon installation; you need to read this password from the server log
  • you have to change this password the first time you connect
  • you cannot use a blank password because of the validate_password plugin
@Mebrouki30

This comment has been minimized.

Copy link

@Mebrouki30 Mebrouki30 commented Jan 16, 2021

root

@dongqifong

This comment has been minimized.

Copy link

@dongqifong dongqifong commented Jan 19, 2021

very thanks~
helpful~

@kaxuna

This comment has been minimized.

Copy link

@kaxuna kaxuna commented Jan 29, 2021

if you have socker(2) error on mac do the following first:

run the command: ($ brew install mysql )
start mysql server: ( $ mysql.server start )
secure mysql server with the password: ( $ mysql_secure_installation )

it worked for me, hope it works for you too :)

@isaac-tribal

This comment has been minimized.

Copy link

@isaac-tribal isaac-tribal commented Feb 27, 2021

Still seeing the "Can't connect to local MySQL server..."

Tried Greggle's link to fully remove a previous install of MySQL 8, but after a restart the problem persists

# brew services start mysql@5.7
==> Successfully started `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)

# launchctl list | grep mysql
-	0	homebrew.mxcl.mysql@5.7

Brew services is reporting the service started, but Launchctl is not showing a PID.

Here is the log output

lee@kezzico:~# tail /usr/local/var/mysql/kezzico.local.err 
2018-10-03T21:57:10.986146Z 0 [ERROR] Can't start server: can't check PID filepath: No such file or directory
2018-10-03T21:57:11.6NZ mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Finally got the service to start by creating a folder for the PID, and setting the permission on the folder to global read/write/x.

# sudo mkdir /var/run/mysqld
# chmod 777 /var/run/mysqld

Not sure why this is necessary. There may be security implications to this. Hopefully someone has a better solution.

Also you can change the mysql folder permissions to the current user.

sudo chown -Rv "$USER":admin /usr/local/var/mysql

@mefuru

This comment has been minimized.

Copy link

@mefuru mefuru commented Mar 1, 2021

Works great until I attempt to create a password for root:

$ mysqladmin -u root password 'yourpassword'

I get the following error:

... Failed! Error: Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50615, now running 50732. Please use mysql_upgrade to fix this error.

Any advice would be much appreciated?

@isaac-tribal

This comment has been minimized.

Copy link

@isaac-tribal isaac-tribal commented Mar 1, 2021

Works great until I attempt to create a password for root:

$ mysqladmin -u root password 'yourpassword'

I get the following error:

... Failed! Error: Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50615, now running 50732. Please use mysql_upgrade to fix this error.

Any advice would be much appreciated?

run this command, it will prompt a form about setting up root password

mysql_secure_installation

@mefuru

This comment has been minimized.

Copy link

@mefuru mefuru commented Mar 1, 2021

Works great until I attempt to create a password for root:
$ mysqladmin -u root password 'yourpassword'
I get the following error:
... Failed! Error: Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50615, now running 50732. Please use mysql_upgrade to fix this error.
Any advice would be much appreciated?

run this command, it will prompt a form about setting up root password

mysql_secure_installation

Did the trick, thanks!

@KeithTt

This comment has been minimized.

Copy link

@KeithTt KeithTt commented Mar 8, 2021

Thanks a lot!!!

@rolasteph

This comment has been minimized.

Copy link

@rolasteph rolasteph commented Apr 5, 2021

I followed the instructions and did a clean install.
I got to the same "mysqladmin" point, but failed differently...

% mysqladmin -u root password '---redacted---'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

To get past this, here's what I ended up having to do:

  • Enter mysql and add a password for “root” user:

    • mysql -u root -p
    • It will prompt for password. THERE IS NO PASSWORD YET, SO JUST HIT ENTER
    • you should get the mysql> prompt
  • At the mysql> prompt:

    • mysql> use mysql;
    • mysql> update user set authentication_string=password("<desired root password>") where user="root";
    • mysql> exit
  • Restart the service to pick up the change:

    • brew services stop mysql@5.7
    • brew services start mysql@5.7

Now, when you do mysql -u root -p it will prompt for password and accept the new password you set above.

@sameeraswal

This comment has been minimized.

Copy link

@sameeraswal sameeraswal commented May 19, 2021

I had to do below steps after following the given instructions:-
sudo mkdir /usr/local/var/mysql
sudo chmod 777 /usr/local/var/mysql
brew services restart mysql@5.7

@seemly

This comment has been minimized.

Copy link

@seemly seemly commented May 24, 2021

When setting up my Apple M1 Macbook Pro I was experiencing the issue of the following error message being thrown:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

My fix was to modify the MySQL config file:

nano /usr/local/etc/my.cnf

Append the following lines:

tmpdir=/tmp
user=root

Then run:

brew services restart mysql@5.7

This fixed my issue, and I was then able to connect successfully with my DB client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment