Reputation: 586
I am trying to configure my server to allow remote connections.
From what I understand I need to uncomment bind-address 127.0.0.1
in the my.cnf file
, then restart mysql.
That hasn't worked.
I have also tried changing it to bind-address 0.0.0.0
.
That hasn't worked either.
When I try to remotely connect using SQLpro, I get the following error:
MySQL said: Can't connect to MySQL server on '54.444.33.4' (4)
Can anybody offer any other solutions?
Thanks.
Upvotes: 2
Views: 17082
Reputation:
First of all; to be able to remotely access your database remotely from another computer etc. You have to give an IP which is either Private or Public and do configurations according to that. In this case, I'll tell you how to do it in LAN :
Do a full fresh installation of MySQL with below commands :
sudo apt-get update
sudo apt-get mysql-server
sudo mysql_install_db
sudo mysql_secure_installation
At the last command, determine a password and press "ENTER" to all other questions it asks during installation to make them default settings.
Go and open terminal and type the command below :
ifconfig
You'll see the Private IP that the router gives you from here, should be something like ex : 192.168.1.10
After you acquire the IP, open the /etc/mysql/mysql.cnf
file and change the bind adress to the IP you've acquired, in this case :
bind-address= 192.168.1.10
Restart the server via,
sudo service mysql restart
After this case, I'll give you some tips for Security. Never allow your root user remotely accessible, that is just unsecure. Type the below commands to make another admin user access the Server from anywhere :
mysql -u root -p
(It will ask you password of mysql root user, type it in and get into mysql line)
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'username'@'IP ADDRESS' IDENTIFIED BY 'password';
I usually give SELECT, UPDATE, DELETE, INSERT to a remote user, but you can give all privileges as well, I'll give you commands for both :
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT SELECT,INSERT,DELETE,UPDATE ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
After all these, restart the service once more and you can connect to your MYSQL Server from any computer connected to the network. Cheers!
Upvotes: 4