您好,登錄后才能下訂單哦!
本篇內容主要講解“Python如何安裝mariadb對應的MySQLdb擴展”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“Python如何安裝mariadb對應的MySQLdb擴展”吧!
debian下安裝
比如網上的方案是:
apt-get install libmysql-dev apt-get install libmysqlclient-dev apt-get install python-dev pip install mysqlclient
這些命令一般情況下是沒問題的,但是本機上安裝的是maraidb,那就扯淡了
MariaDB [(none)]> select version(); +--------------------------+ | version() | +--------------------------+ | 10.1.38-MariaDB-0+deb9u1 | +--------------------------+
搜索apt的源發現沒有相應的libmysql-dev 之類的,搜索如下:
ljf@ljf:/var/www/python$ sudo apt-cache search libmysql libglpk40 - linear programming kit with integer (MIP) support libcrypt-mysql-perl - Perl module to emulate the MySQL PASSWORD() function libmysql-diff-perl - module for comparing the table structure of two MySQL databases libreoffice-base-drivers - Database connectivity drivers for LibreOffice solr-common - Enterprise search server based on Lucene3 - common files libmariadbclient-dev-compat - MariaDB database development files (libmysqlclient compatibility) libmysql++-dev - MySQL C++ library bindings (development) libmysql++-doc - MySQL C++ library bindings (documentation and examples) libmysql++3v5 - MySQL C++ library bindings (runtime) libmysqlcppconn-dev - MySQL Connector for C++ (development files) libmysqlcppconn7v5 - MySQL Connector for C++ (library) libmysql-java - Java database (JDBC) driver for MySQL libmysql-cil-dev - MySQL database connector for CLI libmysql6.4-cil - MySQL database connector for CLI default-libmysqlclient-dev - MySQL database development files (metapackage) libmysql-ocaml - OCaml bindings for MySql (runtime package) libmysql-ocaml-dev - OCaml bindings for MySql (development package) node-mysql - MySQL client implementation for Node.js
搜索出來的源感覺不是那么對,但是有個源的名稱叫:libmariadbclient-dev-compat ,那么會不會是要下載libmariadb的源文件呢,搜索下libmariadb對應的擴展看看:
ljf@ljf:/var/www/python$ sudo apt-cache search libmariadb libmariadbclient-dev - MariaDB database development files libmariadbclient-dev-compat - MariaDB database development files (libmysqlclient compatibility) libmariadbclient18 - MariaDB database client library libmariadbd-dev - MariaDB embedded database, development files libmariadbd18 - MariaDB embedded database, shared library libmariadb-dev - MariaDB Connector/C, development files libmariadb-dev-compat - MariaDB Connector/C, compatibility symlinks libmariadb2 - MariaDB Connector/C default-libmysqlclient-dev - MySQL database development files (metapackage)
果然libmariadb的源文件和推薦命令十分相似,安裝試試:
apt-get install libmariadbd-dev apt-get install libmariadbdclient-dev apt-get install python-dev pip install mysqlclient
執行完畢之后,測試:
ljf@ljf:/var/www/python$ python Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb >>> exit()
到此,相信大家對“Python如何安裝mariadb對應的MySQLdb擴展”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。