How to install MYSQL on Mac OSX

In the previous post I told how to remove Mysql from your system, in the same note let's talk about how to install it correctly. Let's start with a simple one and agree that in the age of package managers it’s at least absurd to install anything manually.

So, to install additional packages in Mac Os, there is an excellent Homebrew component manager that we will use. If you for some reason have not yet installed this wonderful tool, immediately install it with the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Well, now you can, with one team only, install everything on your Mac Os, including MySql. This is how it is simple and fast:

brew install mysql

Since now the current version is now 8.x, but I still prefer 5.7, if you are with the number of such old cities, you will be helped by this command:

brew install mysql@5.7

All our sql server is installed and ready to go into battle. Let's now configure it a bit:

To configure, start the server:

mysql.server start

To connect 

mysql -u root

Set the password to the root user

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

If at this stage you have a problem with the fact that the terminal does not know the MySQL command, perform a link to version 5.7 or the one you have chosen as a favorite

brew link --force mysql@5.7

To start the subsequent launch of the Mysql server

brew services start mysql

To restart 

brew services restart mysql

 

To administer databases in OSX, I prefer to use the Sequel Pro program instead of the notorious PhpMyadmin. You may be interested to try something new for yourself =) By the way, the program is free and damn convenient. Allows you to connect via SSH to your remote servers and the local one is doing just fine!

sequelpro.jpg