Install / Update mysql-connector for Python - mysql

I have had no success at installing the MySQL Python connector on ubuntu 14.04. it appears that the production environment has version 1.1.6 installed. I have tried removing it with both pip and apt-get. I have attempted to update it also and have had no luck.
The command below does not work, I have tried with both "mysql-connector" and "mysql-connector-python"
pip install --user --allow-external mysql-connector-python mysql-connector-python
`
Downloading/unpacking mysql-connector-python Could not find any
downloads that satisfy the requirement mysql-connector-python Cleaning
up... No distributions at all found for mysql-connector-python
Storing debug log for failure in /root/.pip/pip.log`
If I run the command above, with just mysql-connector, it fails with an error about external managment.
"error: option --single-version-externally-managed not recognized"
I have also tried to manually remove it from "/usr/lib/python2.7/dist-packages/mysql_connector_python-1.1.6.egg-info" and that seems to have made no difference.
I have also downloaded the .deb from MySQL:
"mysql-connector-python-cext_2.1.3-1ubuntu14.04_amd64.deb" and used dpkg to install it, but that fails, as well as update fails.
Any advice?

Related

Apache superset on Mac osx

Hi all I am tried to install the superset on OSX using the Python3. After the installation finished when I tried to add the Database using the mysql:// it said error No Module name MySQLDb. I tried to explore how to solved this, one of tutorial said try to install mysqlclient using pip3 install mysqlclient failed to install with error code mysql.h not found.
Than I following another tutorial used the mysql-connector. After I installed it, finally I can connect to mysql DB and insert table to the system. But when I tried to run the analysis from superset it said no data. Also I tried using SQL Lab and got the error args.
Updated: on my superset currently I am used the mysql+mysql-connector as URI Database connected properly, but when I tested to run a query it said execute() got an unexpected keyword argument 'args'. How to solve this?
Anyone have experience with this problem?
Thanks
Here is what works for me:
brew install python || true
brew install mysql || true
# Required for mysqlclient, see brew info openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
# And now it works
pip3 install mysqlclient
Cheers!
Finally I got it working now.
What I am doing is reinstall the superset, run the brew install mysql-connector-c than run pip install mysqlclient

mysql_config not found with mysql-community on CentOS 7

I need to install mysqlclient module for python3.6 on my CentOS server via pip.
The instalation breaks with following error: OSError: mysql_config not found.
I've found a solution, to install mysql-devel package, but unfortunately it breaks with following error:
Error: mariadb101u-config conflicts with mysql-community-server-8.0.4-0.1.rc.el7.x86_64
Error: mariadb101u-libs conflicts with mysql-community-libs-8.0.4-0.1.rc.el7.x86_64
Error: mariadb101u-libs conflicts with mysql-community-libs-compat-8.0.4-0.1.rc.el7.x86_64
Error: mariadb101u-common conflicts with mysql-community-common-8.0.4-0.1.rc.el7.x86_64
I cannot remove the mysql-community packages, because the server is running MySQL database based on that.
Is there any way to fix it without removing conflicting packets?
Ok, found an answer:
yum install mariadb-devel gcc python36u-devel
Solution by #Djent worked for me.
But I kept on receiving time out error while installing through yum. If you are having the same problem. You can manually download the package and install it!
On CentOS
wget https://archive.mariadb.org/mariadb-10.1.39/yum/centos7-amd64/rpms/MariaDB-10.1.38-centos73-x86_64-devel.rpm
rpm -i MariaDB-10.1.38-centos73-x86_64-devel.rpm
For other linux OS, you can find mariadb-devel at https://pkgs.org/download/mariadb-devel
First run the command (take note of python version):
sudo yum install python36-devel
Then install mysqlclient using pip.

Uninstall Share Lib In Linux

I have tried to install MYSQL 5.6.29 on Linux Centos and installed file "MySQL-shared-5.6.29-1.linux_glibc2.5.x86_64" but i found its wrong file which i have installed. Now when i am trying to install correct file "MySQL-shared-5.6.29-1.el6.x86_6" then getting below error.
/usr/share/doc/MySQL-shared-5.6.29/README from install of MySQL-shared-5.6.29-1.el6.x86_64 conflicts with file from package MySQL-shared-5.6.29-
1.linux_glibc2.5.x86_64
My installation was incomplete and only able to install 3 rpm packages. I run "yum remove mysql" but its un-install only one package please guide me to find & un-install MYSQL related packages.
issue fixed through these commands:
rpm -qa|grep -i SQL -- find installed rpm packages
rpm -e -- find installed package and then place the package name
rpm -i package_name.rpm -- to install packages
yum remove mysql-libs

Create a symlink for the libmysqlclient.18.dylib library

I have installed mysql through a pkg installer.
I am trying to start rails server and I am getting the following error.
Library not loaded: libmysqlclient.18.dylib (LoadError)
I am reading that a solution to that is to create a symlink like
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
There is no
/usr/local/mysql/lib/libmysqlclient.18.dylib
file only a
/usr/local/mysql/lib/libmysqlclient.20.dylib file.
I run
sudo find /usr/ -name libmysqlclient.18.dylib
and I can't find the libmysqlclient.18.dylib file.
I encountered a problem like this while setting up a new development environment. I had installed MySQL via homebrew, which gave me version 5.7.9 of MySQL, with the library version libmysqlclient.20.dylib.
In my case, I was setting up a python project. The requirements install failed because the python-MySQL connection piece was looking for libmysqlclient.18.dylib, which was nowhere to be found on my machine.
Downgrading to MySQL 5.6 solved the issue for me:
brew uninstall mysql
brew tap caskroom/versions
brew install mysql56
Now /usr/local/lib/libmysqlclient.18.dylib is present and everything's peachy.
The mysql2 gem which is most likely in your Rails environment is still looking for libmysqlclient.18.dylib (from what must have been a previous mysql install) but the library is no longer there because the recent manual install/upgrade replaced it with libmysqlclient.20.dylib.
The easy fix is to install again mysql2:
gem uninstall mysql2 && gem install mysql2
or better yet:
gem uninstall mysql2 && bundle, if you are on Bundler.
I did not have mysql installed through brew or gem, and was facing the same issue that it was looking for libmysqlclient.18.dylib instead of libmysqlclient.20.dylib. I tried everything mentioned here and at some other threads. Nothing worked. Finally, this worked for me:
pip install mysqlclient
It does not install libmysqlclient.18.dylib, but solves the library not installed and image not found errors.
Hope it helps someone!
Uninstall mysqlclient
Clear cache of your pip
Find folder in which pip wheel cache is stored for mysqlclient and delete it.
Reinstall mysqlclient
mac mojave OS cache will be in this folder: ~/Library/Caches/pip. Follow the steps below:
Find ~/Library/Caches/pips/wheels/ | grep mysql
Delete the file you got.
pip install mysqlclient

Django: cannot connect to mysql

I am new to Django and I try to follow the official tutorial. since I want to connect to mysql (installed on my computer, and i checked mysql module does exit in python command line), I set the ENGINE in setting.py to be django.db.backends.mysql . and then I tried to run
python manage.py syncdb
then I got error message like this:
Error loading MySQLdb module
and I cannot run
pip install mysql-python
the error msg is:
Unable to find vcvarsall.bat
so what is this error? and honestly I am not sure about the difference between mysql-python and mysql-connector-python. Since i tried with "pip install mysql-connector-python" and it tells me that requirement already satisfied...
You need to download the windows binary installer for the MySQL drivers for Python. Installing from source will not work since you do not have the development headers in Windows.
You need to install the mysql python connector
sudo apt-get install python-mysqldb