I'm not getting to get access to mysql externally. I think it's mysql or firewall stuff or some privilege within the mysql.
I already tried doing steps that are on internet. I'll put the process step-by-step to exemplify what I'm doing and to serve as a tutorial for another people that has this same problem:
I'm using:
-ubuntu server 12.04
-mysql-server5.5
-there is NO hardware firewall just software one
1- First I installed mysql with:
sudo apt-get install mysql-server
2- I changed the root password by:
sudo /etc/init.d/mysql stop
sudo mysqld --skip-grant-tables &
mysql -u root mysql
UPDATE user SET Password=PASSWORD('MYPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
3- I give ALL PRIVILEGES to root to any ip:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
4- After I edited the my.cnf
sudo nano /etc/mysql/my.cnf
I commented the lines, as bellow:
#skip-external-locking
#bind-address = 127.0.0.1
5- I edited the iptables to allow MySql 3306:
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
now typing netstat -ant:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN
tcp 0 0 66.123.173.170:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN
tcp 0 0 66.123.173.170:22 189.32.2.232:49167 ESTABLISHED
tcp 0 336 66.123.173.170:22 189.32.2.232:49654 ESTABLISHED
tcp6 0 0 :::110 :::* LISTEN
tcp6 0 0 :::143 :::* LISTEN
tcp6 0 0 :::8080 :::* LISTEN
tcp6 0 0 :::21 :::* LISTEN
tcp6 0 0 :::53 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:953 :::* LISTEN
tcp6 0 0 :::25 :::* LISTEN
tcp6 0 0 :::993 :::* LISTEN
tcp6 0 0 :::995 :::* LISTEN
tcp6 0 0 127.0.0.1:8005 :::* LISTEN
See that port 3306 is open! Am I right?
6- I restarted the mysql:
sudo service mysql start
I typed:
service mysql status
result:
mysql start/running, process 20757
7- I tried to connect to the server:
mysql -h 66.123.173.170 -u root -p
I got this error:
ERROR 2003 (HY000): Can't connect to MySQL server on '66.123.173.170' (111)
When I do:
mysql -h 127.0.0.1 -u root -p
It works opened MySQL> terminal
8- DOUBT: Do you see anything wrong with this process?
OBS: on step 4, I also tried to put the bind address to bid-address = 0.0.0.0 but it didn't solve the problem.
9- DOUBT: If I turn off the MySQL with: service mysql stop
then, can I access the firewall locally with mysql -h 127.0.0.1 -u root -p ?
I did it and I could connect even with mysql stopped/waiting (this was the status given after stop and retrieveing status of MySQL).