01b_安装MySQL_MacOS压缩包安装

2017-02-14  本文已影响28人  ChZ_CC

前面写了在Windows下安装MySQL的过程,以及遇到的坑。后来打算在家也鼓捣一下,于是在Mac上也安装了MySQL,以外的很顺利呢。

以下是压缩包安装的过程。供参考。

  1. 下载压缩包:mysql-5.7.17-macos10.12-x86_64.tar.gz

  2. 解压,移动到/usr/local路径下。快捷键command+shift+G。文件夹的名字修改为mysql

  3. 终端,cd /usr/local/mysql,然后运行初始化命令,启动mysql服务。分别为下面两行代码。

    sudo bin/mysqld --initialize --user=mysql
    sudo support-files/mysql.server start
    

    第一行初始化完成后,会出现这样一句:

    [Note] A temporary password is generated for root@localhost: 1jf)*ZjUwi0O
    

    最后那一串是临时密码,记下来。

  4. 不确定这两行的作用,但是运行了一下。

    alias mysql=/usr/local/mysql/bin/mysql
    alias mysqladmin=/usr/local/mysql/bin/mysqladmin
    

    啊,看上去像是修改环境变量。嗯应该是的,没错。

  5. 然后就可以进去mysql里面了。执行mysql -u root -p,输入上面生成的临时密码(不用拼写,copy也可以的)。

    localhost:mysql ChZ$ mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 6
    Server version: 5.7.17
    
    Copyright (c) 2000, 2016, 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;
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
    

    像这个样子,运行mysql命令会出错,叫你reset密码。重置就重置咯。

  6. 重置密码,执行命令SET PASSWORD = "newpassword";,然后再进行其他操作就没问题了。试试退出再进入,这时候就用你自己设置的新密码就好了。

我的就这样愉快的安装好了,有什么疑问或建议请在下方评论。

上一篇 下一篇

猜你喜欢

热点阅读