I am building a django app and for which i need to configure mysql.I am trying to install mysqlclient module for sql connection and this is what i am trying
The simplest solution that worked for me is:
yum install python-devel mysql-devel
Then install mysqlclient using pip
pip install mysqlclient
I found this solution at https://github.com/r-dbi/RMySQL/issues/197:
I think this is a bug in that custom MariaDB repo. Their package MariaDB-devel-10.2.6-1.fc25.x86_64 only contains a library named:
/usr/lib64/libmariadbclient.a
However their pkg-config yields another name:
> pkg-config --libs mariadb
-lmariadb
You best raise this at the maintainers of that repo. A workaround is to symlink libmariadbclient.a to libmariadb.a:
sudo ln -s /usr/lib64/libmariadbclient.a /usr/lib64/libmariadb.a
That fixes the installation.
So basically to have mysqlclient install in Python 3.6 and CentOS 7 you need to run:
sudo yum install -y python36-devel mysql-devel gcc
sudo ln -s /usr/lib64/libmariadbclient.a /usr/lib64/libmariadb.a
pip install mysqlclient
Open the terminal or login to the workstation/laptop/dev-server using ssh client. Type the following command yum command as a root user:
# yum install mysql
Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.wiredtree.com
* extras: mirrors.serveraxis.net
* updates: bay.uchicago.edu
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.71-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mysql x86_64 5.1.71-1.el6 base 893 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 893 k
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
mysql-5.1.71-1.el6.x86_64.rpm | 893 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-5.1.71-1.el6.x86_64 1/1
Verifying : mysql-5.1.71-1.el6.x86_64 1/1
Installed:
mysql.x86_64 0:5.1.71-1.el6
Complete!
mysql client the basic syntax is:
mysql -u USER-NAME-HERE -h MYSQL-DB-SERVER-IP-ADDRESS-HERE -p DB-NAME
mysql -u nixcraft -h server1.cyberciti.biz -p salesdata
It's complaining about not being able to find mariadb libs. Run the following to find out why:
ld -lmariadb --verbose
This should tell you specifically what gcc is missing.
My guess is that you are missing some MySQL development headers. Install them with:
debian / ubuntu: sudo apt-get install python-dev libmysqlclient-dev
redhat / centos: sudo yum install python-devel mysql-devel
Update: It really is missing MariaDB shared libs. I think on CentOS, this should take care of it:
sudo yum install MariaDB-devel
Final Update: Just use PyMySQL - pure python, no headers required, no need to jump through these kinds of hoops.
I'm having same issue, and I would like to contribute with my answer. I've just installed in my 2 servers running CentOS 7 with MariaDB (10.2.14-MariaDB MariaDB Server) .
$ cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
$ mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is XXXX
Server version: 10.2.14-MariaDB MariaDB Server
I've installed MariaDB, this packages:
$ yum list installed | grep mariadb
MariaDB-client.x86_64 10.3.13-1.el7.centos @mariadb
MariaDB-common.x86_64 10.3.13-1.el7.centos @mariadb
MariaDB-compat.x86_64 10.3.13-1.el7.centos @mariadb
MariaDB-server.x86_64 10.3.13-1.el7.centos @mariadb
galera.x86_64 25.3.25-1.rhel7.el7.centos @mariadb
I found that the problem is that mysqlclient requires mysql-devel packages, which is different from mariadb-devel. Don't install mariadb-devel!
So, to install only mysql-devel, you need to:
$ sudo yum erase MariaDB-devel.x86_64
$ wget link-to-rpm-you-choose
$ sudo rpm -Uvh your-rpm-downloaded
$ sudo yum install mysql-community-devel.x86_64
$ sudo pip install mysqlclient
Collecting mysqlclient
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz (85kB)
100% |████████████████████████████████| 92kB 758kB/s
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-1.4.2.post1
You are using pip version 8.1.2, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Oh, and mysqlclient is the connector recommended by Django. See: https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-db-api-drivers
Good luck and see ya! :-)