Home  >  Article  >  Database  >  How to install mysql with brew

How to install mysql with brew

藏色散人
藏色散人Original
2021-12-01 15:46:533809browse

How to install mysql with brew: 1. Execute the "brew install mysql@5.7" command; 2. Start mysql; 3. Log in to mysql and change the default password.

How to install mysql with brew

The operating environment of this article: macOS10.15 system, mysql5.7 version, macbook pro 2020 computer.

How to install mysql with brew?

Mac uses brew to install mysql

If you do not consider the version, directly execute the following command

brew install mysql

If you want to select a version, just add @version, for example

brew install mysql@5.7

Start mysql after installation

mysql.server start

If the service is not started, the following error will occur

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

To close mysql

mysql.server stop

If you see the success prompt, it means the startup is successful

Starting MySQL
. SUCCESS!

Now log in to mysql, which is password-free by default

mysql -u root

Change the root password, This is the modification method for 8.0

alter user 'root'@'localhost' identified with mysql_native_password by 'root';

If there is a prompt after pressing Enter, it means the modification is successful

Query OK, 0 rows affected (0.00 sec)

Then exit mysql

exit;

Finally log in again

mysql -u root -p

If you enter the password, you will be logged in successfully

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to install mysql with brew. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn