First Check if you have MySQL installed on your Mac.
Type mysql in your terminal
If you have mysql there, you can get different types of messages, one that you might get is this one
Error 1045 (28000): Access denied for user 'username'@'localhost' (using password: NO)
This way you will know you have mysql installed, but if you get an error saying something like;
-bash: /usr/local/bin/mysql: No such file or directory
This way we know that mysql
is not installed, we then go ahead to mysql.com to download the mac version.
click that link above — it already has mac version selected
Double click on the downloaded file.
Follow the installation process, and then when you get to the point where you are asked to create a password, make sure you do create a password you would remember.
Boom! Finish the process and be Happy!
...
That’s not all. that’s the first part!
...
Now that we have MySQL installed, let’s make sure it is accessible anywhere on the computer.
But before that, let’s just check to make sure it is working properly.
Open System Preference and click on MySQL logo
So now that we know it is working, let’s add the PATH, so we can use terminal to access MySQL from anywhere on our system.
Open Terminal
cd to root ~/
then run this command to see all the files you have, just to be sure you have .bash_profile file on your system.
so you run ls -al
and then scroll till you find .bash_profile
If you do not have .bash_profile file
, simply run touch .bash_profile
and you would have created a file called .bash_profile
Now that we have .bash_profile
we open it with the following command;
open -t .bash_profile
This way you open up the .bash_profile
in the text editor and then you should add this line to the file;
export PATH=${PATH}:/usr/local/mysql/bin/
Now you should save the text file and then close the terminal instance.
Restart your terminal and then run mysql -u root -p
in your terminal.
You should get something looking like this.
...
Now you can write your MySQL codes and be Happy! 😁
...
Thank you for your time. I hope you’ve enjoyed reading this article.
Top comments (0)