The MySQL and MariaDB client utilities enable users to interact with the respective database servers, making it possible to query, update, or administer databases without needing a full server installation. Such clients are essential for developers, database administrators, and anyone wanting to interact with a remote database server from their local machine.

Ubuntu repositories, by default, provide both MySQL and MariaDB client packages, giving users the flexibility to choose based on their server setup or personal preference. Installing a client package doesn't interfere with the other, which means you can have both clients installed on the same system and use them interchangeably.

For the sake of clarity and convenience, the steps mentioned below will guide you through the process of installing either the MySQL or the MariaDB client on an Ubuntu system.

Steps to install MySQL or MariaDB client on Ubuntu:

  1. Launch your terminal application.
  2. Update the system's package lists to ensure you get the latest version of the client.
    $ sudo apt update
  3. Install the MySQL client using the apt package manager.
    $ sudo apt install mysql-client

    If you prefer the MariaDB client, replace mysql-client with mariadb-client in the above command.

  4. Confirm the installation by checking the client version.
    $ mysql --version

    If you installed MariaDB client, you should see something like mariadb Ver 15.1 indicating the version of the client.

  5. Use the client to connect to a remote database by providing the necessary credentials.
    $ mysql -h [remote-host] -u [username] -p

    You'll be prompted for the database user password. Ensure you have the correct access rights to the remote database server.

  6. To exit the client interface, type exit or press Ctrl + D.
  7. Optional: If you wish to uninstall the client, use the following command.
    $ sudo apt remove mysql-client

    For removing MariaDB client, replace mysql-client with mariadb-client.

By following these steps, you'll be equipped to communicate with remote database servers using the client utilities. As a best practice, ensure your client version is compatible with the database server version for optimum performance and feature compatibility.

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.