Mac下安装mysql8.0.11

1、下载MySQL Community 版本:8.0.11,本次例子是以dmg安装的方式,下载的文件名为:mysql-8.0.11-macos10.13-x86_64.dmg

  下载地址:https://dev.mysql.com/downloads/mysql/  下载需要自己登录oracle账号

2、下载后双击安装,安装的时候指设置下mysql root密码

3、用工具链接mysql,如果出现提示:

  Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found

  需要重新配置下密码方式

  配置如下:

  • 点击左上角苹果图标,进入系统偏好设置
  • 点击底下部分MySQL提示
  • 点击Initialize Database,初始化数据库
  • 在Please enter a password for the database "root" user: 输入框中输入密码
  • 选中Use Legacy Password Encryption后在点击OK按钮
  • 弹出框中输入系统管理员密码
  • 初始化后再再MySQL页面点击 Start MySQL Server 按钮,启动mysql。在用客户端连服务端,就能正常连接了

4、安装完成后,在命令行中输入mysql命令,提示:-bash: /usr/local/bin/mysql: No such file or directory

  需要把安装的bin的路径放到环境变量中去,设置方法:

  • 用户home 目录下 在.bash_profile 文件中 添加一行   export PATH=$PATH:/usr/local/mysql-8.0.11-macos10.13-x86_64/bin
  • 再执行命令: source .bash_profile 让设置的环境变量生效

到这一步,整个安装mysql 都完成了并能正常使用

 安装完成后,登录mysql ,通过source 命令导入sql文件:

C02M71L9F8J2:Downloads pub_pawf_autotest$ mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 22

Server version: 8.0.11 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> source 20180407.sql

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

Query OK, 0 rows affected (0.00 sec)

 

原文地址:https://www.cnblogs.com/testway/p/9002764.html