Familiar work with databases through a graphical interface often pushes developers away from using the Ubuntu environment, especially in the case of WSL (Windows Subsystem for Linux). However, as it turned out, connecting a graphical client (for example, Navicat) to work with a database on a MySQL server deployed in WSL is quite simple and does not require complex manipulations.
In this short guide, you will learn how to configure the MySQL server and fix the error "1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client" to ensure a successful connection via the Navicat graphical client.
Step 1: Configuring MySQL on WSL
Make sure MySQL is installed and running
If MySQL is not already installed, run the following commands in WSL to install and run it:
sudo apt update
sudo apt install mysql-server
sudo service mysql start
After launching, check its operation:
sudo service mysql status
Step 2: Allow connections from other devices
By default, the MySQL server listens only to local connections (via 127.0.0.1
). To connect from Navicat (or other Windows programs), you need to change this behavior:
- Open the MySQL configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address
setting:
It will look something like this:
bind-address = 127.0.0.1
bind-address = 0.0.0.0
sudo service mysql restart
Step 3: Configure MySQL User for Remote Connections
By default, in MySQL, the root
user can only connect locally. To allow connection from Navicat, follow these steps:
- Log in to MySQL:
sudo mysql -u root
SELECT host, user, plugin FROM mysql.user;
root
to a compatible one:ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '';
FLUSH PRIVILEGES;
SELECT host, user, plugin FROM mysql.user WHERE user = 'root';
EXIT;
Step 4: Find the WSL IP address
To connect via TCP/IP from Windows, we need an IP address assigned by WSL:
ip addr show
Find the IP address of the interface eth0
. Example:
inet 172.24.239.136/20 brd 172.24.255.255 scope global eth0
Here is the WSL IP address: 172.24.239.136.
Step 5: Allow port 3306
To connect from the outside, you need to allow access to the MySQL port (3306
):
- If the WSL firewall (
ufw
) is enabled, run:
sudo ufw allow 3306
Test-NetConnection -ComputerName 172.24.239.136 -Port 3306
If TcpTestSucceeded
is True, access is allowed.
Step 6: Configure the connection in Navicat
Now you can set up a connection in Navicat:
- Open Navicat.
- Create a new connection by selecting Connection → MySQL.
- In the connection settings, specify:
- Connection Name: any name, for example,
MySQL WSL
. - Host Name/IP Address: The IP address of your WSL (for example,
172.24.239.136
). - Port:
3306
. - User Name:
root
. - Password: leave it blank (or specify the password if it is set).
- Click Test Connection.
The result
As a result, we have user settings in MySQL Wsl for remote connections:
Synchronize MySQL on Ubuntu with Navicate on Windows:
Access to the IP and the corresponding WSL port from Windows:
Solution to the problem with authentication of existing users (error - 1251 - Client does not support authentication protocol requested by server):
It only remains to register the following path in the configuration of our database in the project:
Now you can manage your databases on MySQL installed in WSL through the user-friendly Navicat interface!