I have an application that needs the MySQL C++ Connector. Unfortunately, I have been unable to find a binary version of MySQL or MySQL Connector that works on an Amazon EC2 instance. Here are my notes about how I am compiling MySQL and MySQL Connector C++ on Amazon EC2
Firstly, a bit about why this is a problem. Amazon EC2 uses glibc 2.26. The binary distributions use glibc 2.12, 2.17, or 2.28. Unfortunately, I have been unable to get any of them to work. So, I must build things myself. If someone has a better idea, I am all ears. I scoured the Internet attempting an easier solution with no joy.
Fortunately, the source distribution uses cmake, so it is fairly easy to compile the components myself, albeit with a good chunk of extra disk space required.
Firstly, download the source distribution of MySQL. 8.0.25. I tried newer versions, but they require C++17, which Amazon EC2’s default packages use a GCC version that is too old, so I backed up a few versions. A basic gcc/g++ environment is necessary. Things like cmake, build-essentials, etc.
sudo yum install ncurses-devel
tar xzvf mysql_source.tar.gz # or whatever the tar is named
cd mysql-long-named-directory
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/home/me/mysql8025 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/me/boost173 ..