brew search mysql
brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.17_1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/07/07c53f2a0373372d2f613d604b9c17aceedd1a3990a995fc14
######################################################################## 100.0%
==> Pouring mysql-8.0.17_1.mojave.bottle.tar.gz
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
==> Summary
? /usr/local/Cellar/mysql/8.0.17_1: 284 files, 272.4MB
mysql.server start
Starting MySQL
........ SUCCESS!
mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.17 Homebrew
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| component |
| db |
。。。
| user |
+---------------------------+
33 rows in set (0.01 sec)
mysql> alter user 'root'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.01 sec)
不能通过127.0.0.1链接。。。
参考:
mysql 安装了最新版本8.x版本后的报错: the server requested authentication method unknown to the client
PHP错误:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
下面的方法后来我又删了使用上面的
brew install mysql@5.5
brew info mysql@5.5
mysql@5.5: stable 5.5.62 (bottled) [keg-only]
Open source relational database management system
https://dev.mysql.com/doc/refman/5.5/en/
/usr/local/Cellar/mysql@5.5/5.5.62 (320 files, 124.9MB)
Poured from bottle on 2019-03-03 at 00:48:44
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql@5.5.rb
==> Dependencies
Build: cmake ✔
Required: openssl ✔
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
MySQL is configured to only allow connections from localhost by default
To connect:
/usr/local/opt/mysql@5.5/bin/mysql -uroot
mysql@5.5 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mysql@5.5 first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql@5.5/bin:$PATH"' >> ~/.bash_profile
For compilers to find mysql@5.5 you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql@5.5/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.5/include"
To have launchd start mysql@5.5 now and restart at login:
brew services start mysql@5.5
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql@5.5/bin/mysql.server start
source ~/.bash_profile
未完待续。。。