The default path to MySQL on Mac is /usr/local/mysql/bin.
If you type mysql --version, you may get an error saying “command not found.” This is because you don’t have the MySQL command in your path.
To solve this, you can do one of two things:
# This will add MySQL to your current session (will be lost when you close Terminal)
echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
Copy and paste whichever command you prefer into Terminal. Close & reopen your Terminal window after you run the command.
Now, if you type mysql --verison, it should show you your version of MySQL.
Log in and use MySQL in the Terminal using this command: mysql -u root -p. It will ask for your password; make sure you use your MySQL password, not your system password
Ctrl + L to clear the prompt
SELECT User, Host FROM mysql.user;
Create user: When you create a new database for a new application, you will probably want to have a specific user for that database rather than using the root user
CREATE USER 'someuser'@'localhost' IDENTIFIED BY 'somepassword';