by XDK
23. August 2019 20:31
Explanation:
The mention exception occurred while connecting to MySQL database instance remotely.
Exception:
ubuntu@ip-10-0-1-14:~$ sudo mysql -u root -p -h 10.0.2.227
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '10.0.2.227' (111)
Solution:
Login to the data tier where MYSQL server --> Login to MYSQL --> Execute the following steps.
ubuntu@ip-10-0-2-227:~$ sudo mysql -u root -p
ubuntu@ip-10-0-2-227:~$ more /etc/mysql/mysql.cnf
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
Note: Search for bind-address = 127.0.0.1. in /etc/mysql/mysql.cnf. If not found, search for bind-address = 127.0.0.1 in the files under included directories(!includedir).
ubuntu@ip-10-0-2-227:~$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
Comment the bind-address as follows
# bind-address = 127.0.0.1
Save the /etc/mysql/mysql.conf.d/mysqld.cnf file
- Restart mysql to load the recent configuration
ubuntu@ip-10-0-2-227:~$ sudo systemctl restart mysql
ubuntu@ip-10-0-2-227:~$ sudo systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: active (running) since Wed 2019-08-21 18:31:49 UTC; 13s ago
Process: 15835 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/m
Process: 15813 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exi
Main PID: 15837 (mysqld)
Tasks: 27 (limit: 1152)
CGroup: /system.slice/mysql.service
─15837 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pi
ubuntu@ip-10-0-1-14:~$ sudo mysql -u root -p -h 10.0.2.227
963be8d9-6dab-458b-9456-40aaeea72a27|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: exceptions
MySQL