I'm trying to make a MySQL database on my Raspberry Pi 4, but it isn't going very well, using localhost instead works perfectly but I want to remote control it from my Windows 10 computer on the same internet. When I create a user with the address of 192.168.1.15 by doing this:
sudo mysql -u root
CREATE USER 'lasse'@'192.168.1.15' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'lasse'@'192.168.1.15';
FLUSH PRIVILEGES
exit
I try to login again using this:
mysql -u lasse -h 192.168.1.15 -ppassword // didnt work, error: ERROR 2002 (HY000): Can't connect to MySQL server on '192.168.1.15' (115)
mysql -u user -h 192.168.1.2 -P 3306 -ppassword // didnt work either, same error.
I have these packages installed:
mariadb-client
mariadb-server
default-mysql-server
To fix this error, you need to see if MySQL server is already installed and running on your computer. That should start the server and generate the mysql. sock file. You can try to connect to your MySQL server again now.
The error (2002) Can't connect to ... normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server.
If you see the same status, you can run the service by clicking the Start the service link on the left pane. Now you can try to connect again to your MySQL server from the Command Line. To conclude, the ERROR 2002 happens when your computer can’t connect to MySQL server because the socket file is missing.
You can try to connect to your MySQL server again now. If you’re using macOS and installed MySQL using Homebrew, then you need to make sure that the server is started using the following command: Once MySQL is running, you can try to connect using the mysql command again.
We can help you resolve it. Usually, this error occurs if MySQL is not running or if it is not getting connected. At Bobcares, we often get requests from our customers to fix MySQL errors as part of our Server Management Services. Today, let’s get into the details on how our Support Engineers fix this error. Why MySQL error 2002 (hy000) occurs?
This file is created when MySQL server is started and removed when you stop the server. To fix this error, you need to see if MySQL server is already installed and running on your computer. If you’re using Linux, you may need to install mysql-server in addition to the mysql package:
In the file /etc/mysql/mariadb.conf.d/50-server.cnf
(Raspi-os 2021-03-04 with MariaDB installed), you should replace the line "bind-address = 127.0.0.1"
(localhost) by "bind-address = 0.0.0.0"
(all). After, you should restart your MySQL server : $ sudo service mariadb restart
ERROR 2002 is "Can't connect" error. Check out /etc/my.cnf, look for listen line. It may be listening localhost or 127.0.0.1. You need to change it to listen 0.0.0.0.
There are three things
when all conditions are fulfilled, you should be able to connect to mysql database on 192.168.1.15
Error 115 is returned from socket operation (EINPROGRESS), which means that your client can't physically connect to the specified server and port.
The MariaDB database server is not configured correctly, since it doesn't accept remote connections. Please login locally and check the following variables:
SHOW VARIABLES LIKE 'skip_networking'
(result should be off)SHOW VARIABLES LIKE 'bind-address'
(should not be 127.0.0.1)
Since these are read only variables, you need to change them (or comment them out with a #
) in your my.cnf configuration file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With