mac 安装mysql

mac 安装mysql

1. 安装homebrew
2. 用brew 安装mysql

执行brew install mysql,会出现类似的提示:

    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
3. 之后我们按照提示 执行 mysql_secure_installation

发现如下错误

Securing the MySQL server deployment.
Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

这个错误的原因是我们没有开启mysql

4. 开启mysql 服务

执行mysql.server start 会提示 starting mysql, success.

5. 继续执行mysql_secure_installation

会提示你输入root 用户的password,还有其他一些的提示。

6. 进入mysql后台: mysql -u root -p
7. 退出mysql后台: 可以在mysql后台中执行 quit;
8. mysql关闭命令: mysql.server stop

你可能感兴趣的:(数据库)