To get started with setting up my mac for using MySQL, I downloaded a copy of MySQL for mac at dev.mysql.com. After installation I need to modify ‘.zshrc’ and ‘.zprofile’ with the following settings below so terminal could recognise ‘mysql’ command.
PATH=${PATH}:/usr/local/mysql/bin
:bulb: Tip!
If you decide use root account for MySQL, be sure to change password to something different otherwise you may bump into db connection issues with tools like VS Code.
Git and VS Code
I created a git repo to keep track of all the exercises I’ll run through and to make it easy to replay things. I tested a few different MySQL extensions for VS Code and decided to use vscode database.
Example database
To follow along the examples in the Learning SQL book, I downloaded a copy of the sakila Database from here.
Using MySQL CLI
To start working on MySQL database, you first need to initiate a connection to MySQL with the command below. You can optionally specify a database you want to use on after a connection established with the database name after password flag.
mysql -u $username -p;