Home >Database >Mysql Tutorial >How to install mysql with brew
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.
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!