postgresql的mysql外部數據擴展mysql_fdw編譯及安裝


下載mysql_fdw項目文件:https://pgxn.org/dist/mysql_fdw/

注:我使用的是ubuntu18.04,可以直接在倉庫查看是否有二級制安裝文件,當然是有的啦,這是很方便的一個方法

$ sudo apt search fdw
Sorting... Done
Full Text Search... Done
postgresql-10-mysql-fdw/bionic 2.3.0-2 amd64
  Postgres 10 Foreign Data Wrapper for MySQL

 所以直接安裝完事

$ sudo apt install postgresql-10-mysql-fdw 

  

1.好了還是進入正題,首先進入項目目錄

$ cd mysql_fdw/

2.源碼目錄下直接提供的Makefile文件,按理說直接make就可以進行編譯,哈哈哈哈,不會那么簡單的,編譯依賴會讓你對它煩的抓腳,所以看看READ.md吧.

其中說的很清楚:一 需要postgresql相關的依賴由pg_config提供; 二 需要mysql相關的依賴由mysql_config提供

This PostgreSQL extension implements a Foreign Data Wrapper (FDW) for
[MySQL][1].

Please note that this version of mysql_fdw works with PostgreSQL and EDB Postgres Advanced Server 9.5, 9.6, 10, 11, 12, and 13.

1. Installation
---------------
To compile the [MySQL][1] foreign data wrapper, MySQL's C client library is needed. This library can be downloaded from the official [MySQL website][1].

1. To build on POSIX-compliant systems you need to ensure the `pg_config` executable is in your path when you run `make`. This executable is typically in your PostgreSQL installation's `bin` directory. For example:    ```
    $ export PATH=/usr/local/pgsql/bin/:$PATH
    ```
2. The `mysql_config` must also be in the path, it resides in the MySQL `bin` directory.
    ```
    $ export PATH=/usr/local/mysql/bin/:$PATH
    ```
3. Compile the code using make.
    ```
    $ make USE_PGXS=1
    ```
4.  Finally install the foreign data wrapper.
    ```
    $ make USE_PGXS=1 install
    ```
Not that we have tested the `mysql_fdw` extension only on MacOS and Ubuntu systems, but other \*NIX's should also work.

3.接下來開始編譯

 make USE_PGXS=1

會出現下面的報錯

make: mysql_config: Command not found
Makefile:58: ../../src/Makefile.global: No such file or directory
Makefile:59: /contrib/contrib-global.mk: No such file or directory

解決:make: mysql_config: Command not found ,安裝 libmysqlclient-dev

sudo apt install libmysqlclient-dev 

解決

Makefile:58: ../../src/Makefile.global: No such file or directory Makefile:59: /contrib/contrib-global.mk: No such file or directory 安裝 postgresql-server-dev-all,postgresql-common
 
sudo apt-get install postgresql-server-dev-all
sudo apt-get install postgresql-common

4.然后便可以愉快的編譯了 

make USE_PGXS=1 

5.安裝

make USE_PGXS=1 install

  

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM