If you’ve ever ran into issues using Adminer, have a large database that you need to manually import, or just want to do some work in MySQL CLI, then this guide is for you!
This guide also requires that you have Local setup and are using Mac, although similar steps are used to connect on Linux.
This guide is set up to help you connect to Local’s MySQL socket to do whatever you need through MySQL CLI. If you don’t already have MySQL running on your computer, please install MySQL first before continuing. If you already have MySQL installed, continue reading.
Now that you have MySQL installed, let’s visit Local to get the socket information.
- Make sure the site is running.
- Click on Database and you’ll see a screen similar to mine.
- Copy the text in the “Socket” area.
Now on the command line, enter the command shown below and press enter. You should be greeted with MySQL command line.
🎷 ➜ ~ mysql -uroot -proot --socket "/Users/client35/Library/Application Support/Local/run/BqChVVe5X/mysql/mysqld.sock" mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.28 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Happy coding!