This guide needs root access, so it fits VPS and dedicated server customers.
What does the error mean?
You use SSH to type commands on a server. SSH is a safe way to control a remote computer. When you type mysql and see "command not found", one of two things is true.
- MySQL is not installed.
- MySQL is installed, but the system does not know where it is. The system looks for programs in folders listed in a setting called PATH. Think of PATH as a list of places to search.
Step 1: Check if it is installed
- Log in to your server with SSH.
- Type:
This shows where the mysql program is. Nothing printed means it was not found.which mysql - Try a search:
This searches the whole server for a file called mysql. It may take a moment.find / -name mysql -type f 2>/dev/null
Step 2a: It exists but is not in PATH
Say the search found /usr/local/mysql/bin/mysql. You can add its folder to PATH.
- Run:
This adds the folder for your current session only.export PATH=$PATH:/usr/local/mysql/bin - To keep it, add that same line to the end of the file
~/.bashrc. - Run
source ~/.bashrcto load it. - Type
mysql --versionto test.
Step 2b: It is not installed
Install the MySQL client. The command depends on your system.
On Ubuntu or Debian:
sudo apt update
sudo apt install mysql-client
On CentOS, AlmaLinux or Rocky Linux:
sudo yum install mysql
Your server may use MariaDB, a close cousin of MySQL. In that case, install mariadb or mariadb-server instead. Its command is still called mysql.
Warning: Do not install a server package over an existing database server without a backup. You could break your sites.
Check it worked
Type mysql --version. If a version number appears, it works.
Still stuck? Open a support ticket.
Quick recap
- The error means MySQL is missing or not in PATH.
- Use
which mysqlto check. - Add the folder to PATH, or install the client.
- Test with
mysql --version.