美文网首页Mysql
mac本地安装mysql server

mac本地安装mysql server

作者: 天马行空爱做梦 | 来源:发表于2021-01-04 19:28 被阅读0次

    1、打开mac terminal, 输入指令 brew search mysql (用来查看brew里面有哪些可以安装的mysql 版本)
    2、brew install mysql@5.7 用来安装5.7版本的mysql 版本。 安装成功后会有下面的log出来哦。仔细看log内容有提示你该怎么做
    3、上面一步初始安装好之后,是没有配置root的用户名和密码的。这个时候要做的是配置mysql的环境信息。运行下面的指令即可:

    export PATH="$PATH:/usr/local/mysql/bin"
    echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> /Users/XXX/.bash_profile
    export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
    export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
    source ~/.bash_profile
    

    4、进入/usr/local/mysql/bin,查看此目录下是否有mysql,确认有之后
    5、termainal中执行命令 mysql_secure_installation 然后按照提示设置初始root的密码即可。一般设置密码是123456
    6、登录指令是 mysql -uroot -p123456
    7、如果要重置密码的话,可以执行命令:
    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');

    参考:
    brew install mysql@5.7 按照好之后,会打印出来下面的log,初次使用的同学,记得先保存一下。上面的操作指令基本上也是按照下面的log 配置的:

    ==> mysql@5.7
    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
    
    mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    If you need to have mysql@5.7 first in your PATH run:
      echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> /Users/XXX/.bash_profile
    
    For compilers to find mysql@5.7 you may need to set:
      export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
      export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
    
    For pkg-config to find mysql@5.7 you may need to set:
      export PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig"
    
    
    To have launchd start mysql@5.7 now and restart at login:
      brew services start mysql@5.7
    Or, if you don't want/need a background service you can just run:
      /usr/local/opt/mysql@5.7/bin/mysql.server start
    

    相关文章

      网友评论

        本文标题:mac本地安装mysql server

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