十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本篇内容主要讲解“Python如何安装mariadb对应的MySQLdb扩展”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python如何安装mariadb对应的MySQLdb扩展”吧!
成都创新互联主营黄山网站建设的网络公司,主营网站建设方案,成都App制作,黄山h5小程序制作搭建,黄山网站营销推广欢迎黄山等地区企业咨询
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扩展”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!