MySQL and MariaDB are among the most widely adopted open-source relational database management systems (RDBMS) worldwide. Their versatility and robustness have earned them a crucial role in the development of countless applications and services, ranging from small-scale web apps to large enterprise solutions. While MySQL has been available since 1995, MariaDB was introduced in 2009 as a fork of MySQL after Oracle's acquisition. As a result, MariaDB has garnered significant interest and is considered a compatible, feature-rich alternative to MySQL.

To interact with these databases, MySQL and MariaDB provide a variety of clients and tools that facilitate tasks such as database creation and modification, SQL query execution, and user account management. Installing these clients on Linux distributions, including Ubuntu, is a straightforward process.

This guide will outline the steps necessary for installing the MySQL or MariaDB client on an Ubuntu system. The instructions are geared towards a knowledgeable audience, and by following the steps, you'll have a fully functional MySQL or MariaDB client installed on your system.

Steps to install MySQL or MariaDB client on Ubuntu:

  1. Open a terminal window on your Ubuntu system.
  2. Update the package lists for upgrades and package dependencies.
    sudo apt update
  3. Install the MySQL or MariaDB client by selecting the appropriate command based on your preference.
    sudo apt install mysql-client -y
    sudo apt install mariadb-client -y
  4. Confirm the successful installation of your chosen client by checking its version.
    mysql --version
    mariadb --version
  5. (Optional) To enable autocompletion for SQL commands, install the bash-completion package.
    sudo apt install bash-completion -y
  6. (Optional) Activate autocompletion for the current session by running.
    source /etc/profile.d/
    source /usr/share/bash-completion/bash_completion
  7. (Optional) Make autocompletion permanent by adding the following line to your ~/.bashrc file.
    source /etc/profile.d/
    source /usr/share/bash-completion/bash_completion
  8. Reload your bash profile with the command.
    source ~/.bashrc
Discuss the article:

Comment anonymously. Login not required.