美文网首页
2-1. mac 上安装mysql

2-1. mac 上安装mysql

作者: 我的昵称好听吗 | 来源:发表于2019-02-10 15:14 被阅读0次

    mysql 下载地址
    https://downloads.mysql.com/archives/community/

    1. 下载想要的版本

    我下载的是dmg

    image.png

    2. 安装mysql,保存密码!

    点击继续默认安装就可以

    image.png

    安装完成后会出现一个弹窗,不要关闭,这个弹窗上有root用户的密码,先复制保存

    image.png

    如:我安装完成后的密码如下

    • root@localhost: vhpuv4X/ByB6

    3. 配置mysql

    (1) 进入系统偏好设置
    image.png
    (2)启动mysql服务

    开机自启看个人需要
    点击 Start MySqQl Server 启动服务

    image.png
    (3)将mysql加入环境变量
      1. 执行:
    vim ~/.bash_profile
    
      1. 加入:
    export PATH=$PATH:/usr/local/mysql/bin
    
      1. 退出编辑后终端输入
    source ~/.bash_profile
    

    4. 登录mysql

    密码就是刚才安装完成弹窗提示的密码

    mysql -uroot -p
    

    输入密码后有如下提示说明登录成功:

    daiyunzhoudeMacBook-Pro:mysql daiyunzhou$ mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 63
    Server version: 5.7.20
    
    Copyright (c) 2000, 2017, 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>
    

    5. 更新密码

    不修改密码不能用其他工具链接,只能在终端通过mysql -uroot -p登录(这是本人测试的结果,如果不对希望各位大佬提出宝贵的意见)

    1. 修改密码
    SET PASSWORD = PASSWORD('新密码');
    
    1. 选择性设置密码永不过期(可选)
    ALTER USER 'root' PASSWORD EXPIRE NEVER
    
    3. 刷新
    
    ```sh
    flush privileges
    
    如下图所示
    ```sh
    mysql> SET PASSWORD = PASSWORD('这是我的密码,你不要看了')
        -> ALTER USER 'root' PASSWORD EXPIRE NEVER
        -> flush privileges
        ->
    

    6. 通过sequel pro 工具连接

    (1) 下载应用

    链接地址: http://www.sequelpro.com/

    (2) 安装应用

    默认安装即可

    安装完成打开如下所示:

    image.png
    (3)链接数据库
    image.png

    相关文章

      网友评论

          本文标题:2-1. mac 上安装mysql

          本文链接:https://www.haomeiwen.com/subject/iyfxeqtx.html