解决安装mysqlclient出现问题:mysql_config: not found

在这里可以讨论Python3开发技术,插件应用等方面技术

版主: jvip_chen

回复
头像
jvip_chen
社区版主
社区版主
帖子: 136
注册时间: 2019年 1月 5日 13:36 星期六

解决安装mysqlclient出现问题:mysql_config: not found

帖子 jvip_chen » 2019年 10月 29日 09:51 星期二

解决安装mysqlclient出现如下问题:

代码: 全选

Complete output from command python setup.py egg_info:
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-7qo1k7as/mysqlclient/setup.py", line 18, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-7qo1k7as/mysqlclient/setup_posix.py", line 53, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-install-7qo1k7as/mysqlclient/setup_posix.py", line 28, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-7qo1k7as/mysqlclient/

安装mysql:

复制代码

代码: 全选

sudo apt-get install mysql-server mysql-client
然后mysql -V查看mysql是否安装成功

代码: 全选

sudo  apt-get install libmysqlclient-dev python3-dev
然后

代码: 全选

pip install mysqlclient就不会报错找不到'mysql_config'了
# mysql5.7创建用户并授权:
创建数据库

代码: 全选

 mysql> CREATE USER 'office'@'%' IDENTIFIED BY 'office';
 mysql> CREATE DATABASE office DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
 mysql> grant all privileges on office.* to office@'%' identified by 'office';
 mysql> flush privileges;
复制代码


修改密码:

代码: 全选

set password for root@'localhost'=password('xxxx');
注意@'localhost不能省略

回复