✓ Solved
Mysql refusing to connect
Linode
Linode Staff
Hello,
I created a Linode using the Rocky Linux 8 image and installed mysql server. However, when I try to connect to my database server remotely I'm unable to do so. Has anyone encountered something like this before:
root@45-33-66-213:~# mysql -h 66.228.33.44 -u root -p
Enter password:
ERROR 1130 (HY000): Host '66-228-33-44.ip.linodeusercontent.com' is not allowed to connect to this MySQL server
Any helpful thoughts would be great!
1 Reply
astable
Linode Staff
✓ Best Answer
Heya,
I was able to replicate the issue you reported. To fix that, I had to do a couple of things in my Rocky Linux 8 system:
Allow remote access to mysql connections
echo "bind-address = 0.0.0.0" >> /etc/my.cnf.d/mysql-server.cnf
Login to my database server locally and then create a user using with my remote IPv4 address:
[root@66-228-33-44 ~]# mysql -h localhost -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.26 Source distribution
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
CREATE user 'root'@'45.33.66.213' IDENTIFIED BY '********';
Then restart the mysql service:
systemctl restart mysqld
after that, connecting to my Rocky Linux 8 from from my remote host is as easy as pie:
root@45-33-66-213:~# mysql -u root -h 66.228.33.44 -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.26 Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
Hope that helps!
Arty