zoukankan      html  css  js  c++  java
  • 在Mac OS环境下安装MySQL服务

                      在Mac OS环境下安装MySQL服务

                                             作者:尹正杰 

    版权声明:原创作品,谢绝转载!否则将追究法律责任。

      我之前介绍过window环境下安装mysql服务,以及在Linux环境下安装mysql服务,今天我要给大家介绍的是在Mac环境下安装mysql服务。其实安装mysql服务我们也可以像Linux那样,使用brew命令进行安装,但我们此处使用的是绿色方式安装。

     

     

    一.下载mysql服务

    1>.登录mysql的下载列表

      下载地址:https://dev.mysql.com/downloads/mysql/。如下图所示,点击标红的标签。

     2>.下载DMG版本的mysql安装包

     

    3>.跳过登录直接下载mysql服务即可

    二.安装mysql服务

    1>.双击运行下载好的安装包,点击继续

    2>.阅读软件许可协议后,点击继续

     

    3>.点击安装

     

    4>.记住安装的数据库的初始密码(如下图所示,我这里的初始化密码是:M7Rju)ofMFMb)

     

    5>.安装成功

     

    三.启动mysql服务

    1>.进入mysql的系统偏好设置

    2>.点击mysql服务

     

    3>.启动mysql服务

     

    4>. 服务启动成功

     

     

    四.修改mysql的默认密码 

    1>.登录mysql服务器

    2>.更改mysql的默认密码

    set password for 'root'@'localhost' = PASSWORD('yinzhengjie');

    3>.使用修改后的密码登录服务器 

    五>.授权mysql远程主机登录

    1>.授权只运行的主机

    [尹正杰到此一游:~ yinzhengjie$ mysql -u root -pyinzhengjie
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 35
    Server version: 5.7.24 MySQL Community Server (GPL)
    
    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> 
    [mysql> 
    [mysql> 
    [mysql> 
    [mysql> grant all privileges on *.* to 'root'@'172.30.1.%' identified by 'yinzhengjie';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    [mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.01 sec)
    
    [mysql> quit
    Bye
    [尹正杰到此一游:~ yinzhengjie$ 

    2>.查看宿主机的IP地址

     

    3>.使用Guest虚拟机登录宿主机 

    六.安装MySQL8.0.x的区别

    1>.MySQL加密方式的选择(之前的安装步骤和上面MySQL5.7的安装方式基本雷同,我这里就省略了~)

    2>.自定义root的密码:

    3>.安装成功后,点击完成

    4>.在MacOS到系统偏好设置进入到MySQL到管理界面

    5>.查看MySQL的默认配置

     

    6>.登陆MySQL服务器 

    7>.将MySQL的安装路径手动添加到环境变量中

    bogon:~ yinzhengjie$ vi ~/.bash_profile 
    bogon:~ yinzhengjie$ 
    bogon:~ yinzhengjie$ source  ~/.bash_profile 
    bogon:~ yinzhengjie$ 
    bogon:~ yinzhengjie$ cat  ~/.bash_profile  | grep PATH
    # Setting PATH for Python 3.6
    PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}:/usr/local/mysql/bin"
    export PATH
    bogon:~ yinzhengjie$ 
    bogon:~ yinzhengjie$ mysql -uroot -pyinzhengjie
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 12
    Server version: 8.0.14 MySQL Community Server - GPL
    
    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.00 sec)
    
    mysql> 

    8>.创建MySQL到登陆用户

    mysql> CREATE USER 'yinzhengjie'@'172.30.1.10%' IDENTIFIED BY 'yinzhengjie';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> 
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'yinzhengjie'@'172.30.1.10%' WITH GRANT OPTION;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> 
    [root@node110 ~]# hostname
    node110.yinzhengjie.org.cn
    [root@node110 ~]# 
    [root@node110 ~]# hostname -i
    172.30.1.110
    [root@node110 ~]# 
    [root@node110 ~]# mysql -h 172.30.1.2 -uyinzhengjie -pyinzhengjie
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ERROR 1130 (HY000): Host '172.30.1.110' is not allowed to connect to this MySQL server
    [root@node110 ~]# 
    [root@node110 ~]# 
    使用 “node110.yinzhengjie.org.cn” 节点登陆
    [root@node105 ~]# hostname
    node105.yinzhengjie.org.cn
    [root@node105 ~]# 
    [root@node105 ~]# hostname -i
    172.30.1.105
    [root@node105 ~]# 
    [root@node105 ~]# mysql -h 172.30.1.2 -uyinzhengjie -pyinzhengjie
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 14
    Server version: 8.0.14 MySQL Community Server - GPL
    
    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.00 sec)
    
    mysql> quit
    Bye
    [root@node105 ~]# 
    使用 “node105.yinzhengjie.org.cn” 节点登陆
  • 相关阅读:
    面向对象的链式调用
    浅显易懂的理解JavaScript中的this关键字
    js 页面刷新location.reload和location.replace的区别小结
    JavaScript中两种类型的全局对象/函数
    event.srcElement ,event.fromElement,event.toElement
    json jsonp的区别
    createElement与createDocumentFragment的点点区别
    解决Ajax不能跨域的方法
    mysqli_fetch_assoc php的新的库函数
    500 501 502 503 504 505 服务器错误
  • 原文地址:https://www.cnblogs.com/yinzhengjie/p/10125609.html
Copyright © 2011-2022 走看看