Installing MySQL Client tools, binaries, and library on Ubuntu Linux

This short tutorial shows you how to install MySQL Client tools, binaries, and library on Ubuntu Linux Server. The process is very simple. For this tutorial, I'll be installing MySQL Client tools, binaries, and library version 5.0.45. Linux kernel is 2.6.15-26-powerpc. I have used a Mac Mini (powerpc/ppc architecture). GCC version number is 4.0.3. Your configuration may be different from mine but the installation steps below should work fine for most configurations with little or no change at all (including other Linux distributions and even unixes e.g. MacOS x).

NOTE: I am not going to explain how to install MySQL Database Server (DBMS System) in this tutorial. This tutorial only explains how to install the client libraries, so that other software (e.g. PHP) can use the libraries to access MySQL Server installed on some other computer. Also, note that I am going to compile and install the client, so please do not message me and tell me that this can be done using Ubuntu package manager. I already know that and also know the commands but I am only showing another method for installation to people like me who want to do everything themselves. This tutorial will also be of some benefit to people who like to try the latest releases.

Before starting, please check to see if there is a latest version available to download. Visit http://dev.mysql.com/downloads/mysql/5.0.html#source to find out about the latest available versions of MySQL version 5. IMPORTANT: See "Configuring Ubuntu Linux After Installation" to install the development tools required to compile and install MySQL Client from source code.

Steps to download, compile, and install are as follows. Note: Replace 5.0.45 with your version number:
  • Before installing MySQL Client you have to install the development packages of libncurses and zlib, so let us do that by running the commands below.

    apt-get install libncurses5-dev
    apt-get install zlib1g-dev
    
  • Downloading MySQL:

    Run the command below,
    wget 
    http://dev.mysql.com/get/Downloads/MySQL-5.0/
    mysql-5.0.45.tar.gz/from/http://mysql.mirror.rafal.ca/
    

    I downloaded the source file from a Canadian mirror. Please visit http://dev.mysql.com/downloads/mysql/5.0.html#source to find a mirror near you.

    Also, download the MD5 hash to verify the integrity of the downloaded file.

    wget 
    http://dev.mysql.com/get/Downloads/MySQL-5.0/
    mysql-5.0.45.tar.gz.md5/from/http://mysql.mirror.rafal.ca/
    

    Click here to find out how to check the integrity of downloaded files using MD5Sums. You can also get the MD5Sum signature (in red circle in the image below) from MySQL's website (recommended) on the downloads page.

    MySQL Download Page

    Please note that if you are using MySQL client for a highly secure/critical setup (or for any other reason) then you should also check the PGP signatures (not covered in this tutorial for simplicity).

  • Extracting files from the downloaded package:

    tar -xvzf mysql-5.0.45.tar.gz

    Now, enter the directory where the package is extracted.

    cd mysql-5.0.45

  • Installing zlib:

    Click here to find out how to install zlib before configuring and installing MySQL client libraries and tools.

  • Configuring MySQL source code:

    ./configure --without-server --enable-thread-safe-client 
      --with-client-ldflags=-all-static --prefix=/usr/local/mysql 
       --with-machine-type=powerpc --with-zlib-dir=/usr/local/zlib 
        --without-debug  --without-docs --with-big-tables 
    
    Replace "/usr/local/mysql" with the path where you want to install MySQL libraries and also replace "/usr/local/zlib" with your zlib directory. You also have to replace "powerpc" with your architecture type. Note: check for any error message.
  • Compiling MySQL source code:

    make

    Note: check for any error message.

  • Installing MySQL source code:

    As root (for privileges on destination directory), run the following.

    With sudo,

    sudo make install

    Without sudo,

    make install

    Note: check for any error messages.

  • More Configuration (setting PATH variable and library path):

    sudo echo '/usr/local/mysql/lib/' >> /etc/ld.so.conf
    sudo ldconfig
    

    Also, run the following.

    PATH=$PATH:/usr/local/mysql/bin
    

    Replace "/usr/local/mysql" with your installation directory. If you are running the BASH shell then do the following to make changes to PATH variable permanent.

    echo "PATH=$PATH:/usr/local/mysql/bin" >> ~/.bash_profile
    
  • Testing the installation:

    Run the command below

    mysql -h192.168.5.15 -utest -p
    

    Replace "192.168.5.15" with your MySQL server host name and "test" with your user name (user name on MySQL database server). You'll be prompted for a password. Enter the password. If the password is entered correctly you should see MySQL client console (see the image below).

    MySQL command line console

That’s it. MySQL Client tools, binaries, and library have been successfully installed.

Did this tutorial help a little? How about buy me a cup of coffee?

Buy me a coffee at ko-fi.com

Please feel free to use the comments form below if you have any questions or need more explanation on anything. I recommend thoroughy testing on a production-like test system first before moving to production.

Comments (write a comment):

apt-get install libmysqlclient15-dev

that's all you need to do. Posted by: Gorth on Mar 09, 2013

Thanks for the instructions, the newer MySQL 5.6.15 doesn't have 'configure' file but need 'cmake' to build, how to use this to install the client component only and in a custom directory?
we have to build the client ourselves from source code as non-root users and hence cannot use the apt-get or yum repository
Thanks,
-srinivas y. Posted by: sri on Jan 28, 2014

@sri: I am not sure how to install the client libraries only using the newer version. But, you can always compile and install the full server and use client binaries from inside bin/ directory.

See http://www.geeksww.com/tutorials/database_management_systems/mysql/installation/download_configure_compile_and_install_mysql_56.php for how to install mysql server 5.6.x Posted by: shahryar on Apr 08, 2014

leave a comment on tutorial leave a comment