当前位置: 代码迷 >> 综合 >> Mac 安装 MySQL 客户端并为 DBeaver 配置 mysqldump 导出命令
  详细解决方案

Mac 安装 MySQL 客户端并为 DBeaver 配置 mysqldump 导出命令

热度:10   发布时间:2023-12-08 12:42:04.0

文章目录

        • 一、场景描述
        • 二、安装 MySQL Client
        • 三、DBeaver 配置 MySQL Client

一、场景描述
  • 在项目开发过程中,经常需要连接远程环境的数据库做相应的操作

  • DBeaver 是一款非常实用(社区版免费)的数据库连接客户端工具

  • 在采用 DBeaver 进行导出数据库时,提示没有本地客户端的情况

  • 为解决这一问题,我们需要在 Mac 上安装 MySQL 客户端,仅仅如此

二、安装 MySQL Client
  1. 打开 Iterm2 终端工具并采用 brew 安装 mysql-client

    brew install mysql-client
    
  2. 安装完成以后特别提示信息如下

    mysql-client is keg-only, which means it was not symlinked into /usr/local,
    because it conflicts with mysql (which contains client libraries).If you need to have mysql-client first in your PATH run:echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrcFor compilers to find mysql-client you may need to set:export LDFLAGS="-L/usr/local/opt/mysql-client/lib"export CPPFLAGS="-I/usr/local/opt/mysql-client/include"
    
  3. 此刻 Mac 电脑就包含了 MySQL 客户端的一些基本命令,根据以上提示,为了不和 MySQL 服务器的安装位置冲突,所以不在环境变量中

    ? /usr/local/Cellar/mysql-client/8.0.22/bin/ pwd
    /usr/local/Cellar/mysql-client/8.0.22/bin
    ? /usr/local/Cellar/mysql-client/8.0.22/bin/ ll
    total 252040
    -r-xr-xr-x  1 rambo  admin  6534584  3  5 10:55 comp_err
    -r-xr-xr-x  1 rambo  admin  6569892  3  5 10:55 lz4_decompress
    -r-xr-xr-x  1 rambo  admin  6506948  3  5 10:55 my_print_defaults
    -r-xr-xr-x  1 rambo  admin  7413736  3  5 10:55 mysql
    -r-xr-xr-x  1 rambo  admin     5155  3  5 10:54 mysql_config
    -r-xr-xr-x  1 rambo  admin  6522772  3  5 10:55 mysql_config_editor
    -r-xr-xr-x  1 rambo  admin  7293332  3  5 10:55 mysql_secure_installation
    -r-xr-xr-x  1 rambo  admin  6551612  3  5 10:55 mysql_ssl_rsa_setup
    -r-xr-xr-x  1 rambo  admin  7303016  3  5 10:55 mysqladmin
    -r-xr-xr-x  1 rambo  admin  7705840  3  5 10:55 mysqlbinlog
    -r-xr-xr-x  1 rambo  admin  7315720  3  5 10:55 mysqlcheck
    -r-xr-xr-x  1 rambo  admin  7378184  3  5 10:55 mysqldump
    -r-xr-xr-x  1 rambo  admin  7305580  3  5 10:55 mysqlimport
    -r-xr-xr-x  1 rambo  admin  8025404  3  5 10:55 mysqlpump
    -r-xr-xr-x  1 rambo  admin  7298132  3  5 10:55 mysqlshow
    -r-xr-xr-x  1 rambo  admin  7321228  3  5 10:55 mysqlslap
    -r-xr-xr-x  1 rambo  admin  8263260  3  5 10:55 mysqltest
    -r-xr-xr-x  1 rambo  admin  7220608  3  5 10:55 perror
    -r-xr-xr-x  1 rambo  admin  6472532  3  5 10:55 zlib_decompress
    
  4. 验证命令是否可用

    ? /usr/local/Cellar/mysql-client/8.0.22/bin/ ./mysql -u root -h 192.169.7.42 -P 3306 -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 37736
    Server version: 8.0.20 MySQL Community Server - GPLCopyright (c) 2000, 2020, 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           |
    +--------------------+
    | exercise           |
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    4 rows in set (0.00 sec)mysql>
    
三、DBeaver 配置 MySQL Client
  1. 未配置前使用 DBwaver 导出报错信息为

    右击需要导出的数据库 -> 工具 -> Dump database

    1

  2. 打开 DBeaver 客户端工具

    右击数据库连接 -> 编辑连接 -> 选择本地客户端 -> 目录指向 MySQL Client 二进制文件夹目录

    2

  3. 导出数据库测试(根据需要选择)

    3

  4. 导出成功界面如下

    4

  相关解决方案