im@markvi.eu

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)"

With just one command, you can now easily install everything you need on your Mac OS, including MySQL. It's quick and simple to do, just run a command:

brew install mysql

If you prefer MySQL version 5.7 over the current version 8.x, you can use the following command to install it using Homebrew:

brew install mysql@5.7

This will install MySQL version 5.7 on your Mac OS using Homebrew. If you have a different version of MySQL that you prefer, you can replace 5.7 with the version number you want to install.

Keep in mind that MySQL version 8.x includes several new features and improvements over previous versions, so you may want to consider upgrading if possible. However, if you have specific requirements or compatibility issues that require you to use an older version, the above command should help you install it.

Once the installation is complete, start the MySQL server by running the following command:

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 ensure that MySQL starts automatically at login, run the following command:

brew services start mysql

To restart

brew services restart mysql

For administering MySQL databases on MacOS, I prefer to use Sequel Pro App instead of the commonly used PhpMyAdmin or the single-file Adminer PHP interface. Sequel Pro is a powerful, user-friendly MySQL management tool that allows you to easily connect to and manage your MySQL databases.

Similar Articles