1、安装
>brew install mysql;
Please wait for it to finish or terminate it to continue.
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.12.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mysql-8.0.12.mojave.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.12/bin/mysqld --initialize-insecure --user=stone --basedir=/usr/local/Cellar/mysql/8.0.12 --datadir=/usr/loca
==> 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
2、mysql 服务启用、停止、重启
>mysql.server start
Starting MySQL
. SUCCESS!
>mysql.server stop
Shutting down MySQL
... SUCCESS!
>mysql.server restart
Shutting down MySQL
.. SUCCESS!
Starting MySQL
. SUCCESS!
3、mysql命令行登入
mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12 Homebrew
Copyright (c) 2000, 2018, 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>