Local Community

How to SSH into your MySQL database in Local on a Mac using zsh

Hey there, I struggled to find a way to access the MySQL database in Local using the Mac terminal. There are lots of posts in here about it that really get into the weeds, but never really solved my problem(or maybe I’m just not quite a power user yet). Anywho, here’s how I did it in three easy steps:

  1. Don’t panic
  2. Right-click a site you have in Local (do this in the left-hand toolbar) and select “Open site shell.”
  3. In the new terminal that should have opened up that may look something like the below, enter “mysql -hlocalhost -P33060 -u[Insert username] -p[Insert password]”

~/Local Sites/[your website name]/app/public $ [where you type the command in 3]

You can find your username and password by clicking on one of your sites in Local, selecting the database tab at the top, and using the username and password found there. Also, make sure your username and password come right after the “-u” and the “-p” - no spaces.

And zsh for those who don’t know is Mac’s terminal. It used to be bash, but now it’s called zsh (for Z shell). When you open your mac terminal and look at the top of the little box you can see it saying zsh (but it could say bash if you decided to change it to bash).

SSHing into something is also lingo for connecting to the database.

And if you still can’t get it to work, chatGPT may help you out. ChatGPT told me to enter the terminal command in step 3 :wink:

What I’m Using:
MacOS Big Sur 11.7.2, MacBook Pro

1 Like