使用Linux安裝MySQL時的問題

分享于 

4分钟阅读

互联网

 

问题:

在Linux机器上安装MySQL时遇到一个奇怪的问题。

我试图将MySQL配置为后端数据库,以在Airflow上工作,以下是配置:


Operating System: Red Hat Enterprise Linux Server 7.7


python 3.7.2


anaconda 3


spark 2.45



我能够连接到MySQL,但是在运行airflow initdb命令时遇到一个错误,

错误:


[2020-04-09 05:19:00,990] {settings.py:253} INFO - settings.configure_orm(): Using pool settings. pool_size=5, max_overflow=10, pool_recycle=1800, pid=15499


Traceback (most recent call last):


 File"/home/npa/anaconda3/envs/python3.7.6/bin/airflow", line 25, in <module>


 from airflow.configuration import conf


 File"/home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/airflow/__init__.py", line 47, in <module>


 settings.initialize()


 File"/home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/airflow/settings.py", line 377, in initialize


 configure_orm()


 File"/home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/airflow/settings.py", line 266, in configure_orm


 engine = create_engine(SQL_ALCHEMY_CONN, **engine_args)


 File"/home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py", line 479, in create_engine


 return strategy.create(*args, **kwargs)


 File"/home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 87, in create


 dbapi = dialect_cls.dbapi(**dbapi_args)


 File"/home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi


 return __import__("MySQLdb")


 File"/home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in <module>


 import _mysql


ImportError: /home/npa/anaconda3/envs/python3.7.6/lib/python3.7/site-packages/_mysql.cpython-37m-x86_64-linux-gnu.so: symbol mysql_real_escape_string_quote, version libmysqlclient_18 not defined in file libmysqlclient.so.18 with link time reference




答案1:

我通过创建指向库的符号链接解决了这个问题。

实际的库驻留在


/usr/local/mysql/lib



然后我创建了一个符号链接

 
/usr/lib



使用命令:


sudo ln -s /usr/local/mysql/lib/libmysqlclient_18 /usr/lib/libmysqlclient_18



我有以下映射:


ls -l libmysqlclient_18 



lrwxr-xr-x 1 root wheel 44 16 Jul 14:01 libmysqlclient_18 -> /usr/local/mysql/lib/libmysqlclient_18




答案2:

我最终使用了以下命令,


yum remove mysql-server


pkill mysqld; pkill mysqld_safe


rpm -qa | grep mysql


yum remove <name displayed in above step-1>


sudo -H pip uninstall mysqlclient


sudo -H pip install --no-binary mysqlclient mysqlclient



rm -rf ~/anaconda3


conda install anaconda-clean


anaconda-clean



然后我再次安装并配置Anaconda和MySQL,问题得到解决。



相关文章