Introduction
The official MySQL Client mysql
, also known as MySQL CLI is a CLI to interact with your MySQL server. Below describe how to install it on Mac, Ubuntu, Debian and Windows respectively.
Before You Start
Before you start, you should confirm that you don't have MySQL client installed. If you have installed MySQL server before, likely you will have MySQL client installed as well. If you see something like below, then MySQL client is already installed and you can stop reading now.
$ mysql --version
mysql Ver 8.0.31 for macos13.0 on arm64 (Homebrew)
Test Connection
After you install the MySQL client following the below instruction, you can test the connection to your MySQL server using
mysql -h hostname -u username -p
Install on Mac
Homebrew
To install MySQL Shell using Homebrew, you need to install Homebrew on your Mac first. If you aren’t sure if you have installed Homebrew already, open your terminal and run the following command to check.
brew -v
If not installed, run the following command to install Homebrew first:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once Homebrew is installed, run the following command to update the list of available packages:
brew update
To install the MySQL client, run the following command:
brew install mysql-client
After the installation is complete, you can verify that the MySQL client is installed by running the following command:
mysql --version
Note: If you have previously installed the MySQL server using Homebrew, you may need to run the following command to link the MySQL client:
brew link --overwrite mysql-client
DMG Package
- Go to the MySQL website and download the DMG package for the MySQL client. The current version can be found at https://dev.mysql.com/downloads/mysql/.
- Double-click the downloaded DMG file to mount it. A new window will appear with the MySQL package.
- Double-click the package to start the installation process, and follow the on-screen instructions to complete the installation.
- Once the installation is complete, you can verify that the MySQL client is installed by opening a Terminal window and running the following command:
mysql --version
This should display the version number of the MySQL client that you just installed.
Note: If you have previously installed the MySQL server using a package manager like Homebrew, you may need to specify the path to the MySQL client binary when running commands. The default location for the MySQL client binary installed with the DMG package is /usr/local/mysql/bin/mysql.
Ubuntu (apt-get)
- Open a terminal window on your Ubuntu machine. You can do this by pressing Ctrl+Alt+T on your keyboard.
- Update the package list and upgrade any installed packages by running the following commands:
sudo apt-get update
sudo apt-get upgrade
Install the MySQL client by running the following command:
sudo apt-get install mysql-client
After the installation is complete, you can verify that the MySQL client is installed by running the following command:
mysql --version
CentOS (yum)
- Open a terminal window on your CentOS machine. You can do this by pressing Ctrl+Alt+T on your keyboard.
- Update the package list and upgrade any installed packages by running the following commands:
sudo yum update
- Install the MySQL client by running the following command:
sudo yum install mysql
- After the installation is complete, you can verify that the MySQL client is installed by running the following command:
mysql --version
Windows
- Go to the MySQL website and download the MySQL Installer for Windows at https://dev.mysql.com/downloads/installer/.
- Run the MySQL Installer and select the "Custom" installation type.
- In the "Select Products and Features" screen, expand the "MySQL Servers" option and uncheck all the server components.
- In the same screen, expand the "Applications" option and check the "MySQL Shell" and "MySQL Workbench" options. These applications include the MySQL client.
- Complete the rest of the installation process.
- After the installation is complete, you can verify that the MySQL client is installed by opening a Command Prompt or PowerShell window and running the following command:
mysql --version
More MySQL Tools
The classic MySQL client is still the most widely used MySQL client. Meanwhile you can also check out following tools
-
MySQL Shell
mysqlsh
introduced in MySQL 8.0 to provide more advanced features overmysql
- Top MySQL GUI client
- Top MySQL Schema Compare Tool to Diff and Sync Database
- Top Free Open Source SQL Clients
Top comments (0)