Edited at

mysql_confがない場合(mysql-community-serverを使っていて)

More than 1 year has passed since last update.

リポジトリの標準でないバージョンにmysqlを入れたいとき、mysql-community-serverを入れることはよくあると思います。

その関連でひっかかったエラーを忘備録として残します。(あんまりググっても引っかからなかったので)


遭遇したエラーと解決策


  • エラー



    • pip install flask-mysqldb時にOSError: mysql_config not found



  • 解決策


    • sudo yum install mysql-community-devel




遭遇したエラー


  • # pip install flask-mysqldb

  • 以下のエラーメッセージ

Collecting flask-mysqldb

Using cached Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): Flask>=0.10 in /root/.pyenv/versions/3.5.1/lib/python3.5/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
Using cached mysqlclient-1.3.9.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-xnry20_a/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-xnry20_a/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-xnry20_a/mysqlclient/setup_posix.py", line 26, 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-build-xnry20_a/mysqlclient
Y


  • 重要なのはここですOSError: mysql_config not found

  • たしかにない

# ll /usr/bin/mysql_config*

-rwxr-xr-x 1 root 8771007 Nov 28 20:30 /usr/bin/mysql_config_editor*


私の環境


  • 以下の一連コマンドでmysql5.7.17をインストールしてた


    • yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

    • yum -y install mysql-community-server



  • yum でなにがinstalledか確認

# yum list installed |grep mysql

mysql-community-client.x86_64 5.7.17-1.el7 @mysql57-community
mysql-community-common.x86_64 5.7.17-1.el7 @mysql57-community
mysql-community-libs.x86_64 5.7.17-1.el7 @mysql57-community
mysql-community-server.x86_64 5.7.17-1.el7 @mysql57-community
mysql57-community-release.noarch el7-7 @/mysql57-community-release-el7-7.noarch


  • community-serverパッケージでinstall可能なもの


    • 長いんで一部抜粋



[root@localhost flaskr]# yum list available | grep mysql |grep community

mysql-community-client.i686 5.7.17-1.el7 mysql57-community
mysql-community-common.i686 5.7.17-1.el7 mysql57-community
mysql-community-devel.i686 5.7.17-1.el7 mysql57-community
mysql-community-devel.x86_64 5.7.17-1.el7 mysql57-community
mysql-community-embedded.i686 5.7.17-1.el7 mysql57-community
mysql-community-embedded.x86_64 5.7.17-1.el7 mysql57-community
mysql-community-embedded-compat.i686 5.7.17-1.el7 mysql57-community
mysql-community-embedded-compat.x86_64 5.7.17-1.el7 mysql57-community
mysql-community-embedded-devel.i686 5.7.17-1.el7 mysql57-community
mysql-community-embedded-devel.x86_64 5.7.17-1.el7 mysql57-community
mysql-community-libs.i686 5.7.17-1.el7 mysql57-community
mysql-community-libs-compat.i686 5.7.17-1.el7 mysql57-community
mysql-community-libs-compat.x86_64 5.7.17-1.el7 mysql57-community
mysql-community-release.noarch el7-7 mysql57-community
mysql-community-test.x86_64 5.7.17-1.el7 mysql57-community


  • mysql-community-devel.x86_64が一番あやしいのでyum installして解決

  • 実際にありました

# ll /bin/mysql_config*

-rwxr-xr-x 1 root 840 Nov 28 20:24 /bin/mysql_config*
-rwxr-xr-x 1 root 4907 Nov 28 20:30 /bin/mysql_config-64*
-rwxr-xr-x 1 root 8771007 Nov 28 20:30 /bin/mysql_config_editor*