Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -ubuntu server 12.04
- -mysql-server5.5
- -there is NO hardware firewall just software one
- sudo apt-get install mysql-server
- 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;
- mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
- mysql> FLUSH PRIVILEGES;
- sudo nano /etc/mysql/my.cnf
- #skip-external-locking
- #bind-address = 127.0.0.1
- iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
- 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
- sudo service mysql start
- service mysql status
- mysql start/running, process 20757
- mysql -h 66.123.173.170 -u root -p
- ERROR 2003 (HY000): Can't connect to MySQL server on '66.123.173.170' (111)
- mysql -h 127.0.0.1 -u root -p
- import java.io.IOException;
- import java.net.ServerSocket;
- public class PortMysqlTest {
- public static void main(String[] args) {
- int port = 3306;
- ServerSocket ss = null;
- try
- {
- ss = new ServerSocket(port);
- ss.setReuseAddress(true);
- }
- catch (IOException e)
- {
- System.out.println(e.getMessage());
- }
- long futureTime = System.currentTimeMillis() + 1000 * 60 * 2;
- while (System.currentTimeMillis() < futureTime)
- {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- if (ss != null)
- {
- try
- {
- ss.close();
- }
- catch (IOException e)
- {
- System.out.println(e.getMessage());
- }
- }
- }
- sudo service mysql stop
- /etc/init.d/mysql stop
- sudo netstat -lpn | grep 3306
- tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 6736/mysqld
- kill -9 6736
- sudo service mysql start
- sudo /etc/init.d/mysql start
- telnet 66.123.173.170 3306
- mysql -h 66.123.173.170 -u root -p
- bind-address = 0.0.0.0
- bind-address = *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement