Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. -ubuntu server 12.04
  2. -mysql-server5.5
  3. -there is NO hardware firewall just software one
  4.  
  5. sudo apt-get install mysql-server
  6.  
  7. sudo /etc/init.d/mysql stop
  8. sudo mysqld --skip-grant-tables &
  9. mysql -u root mysql
  10. UPDATE user SET Password=PASSWORD('MYPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
  11.  
  12. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
  13. mysql> FLUSH PRIVILEGES;
  14.  
  15. sudo nano /etc/mysql/my.cnf
  16.  
  17. #skip-external-locking
  18. #bind-address = 127.0.0.1
  19.  
  20. iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
  21.  
  22. Active Internet connections (servers and established)
  23. Proto Recv-Q Send-Q Local Address Foreign Address State
  24. tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
  25. tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN
  26. tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN
  27. tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN
  28. tcp 0 0 66.123.173.170:53 0.0.0.0:* LISTEN
  29. tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
  30. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
  31. tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
  32. tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
  33. tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN
  34. tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN
  35. tcp 0 0 66.123.173.170:22 189.32.2.232:49167 ESTABLISHED
  36. tcp 0 336 66.123.173.170:22 189.32.2.232:49654 ESTABLISHED
  37. tcp6 0 0 :::110 :::* LISTEN
  38. tcp6 0 0 :::143 :::* LISTEN
  39. tcp6 0 0 :::8080 :::* LISTEN
  40. tcp6 0 0 :::21 :::* LISTEN
  41. tcp6 0 0 :::53 :::* LISTEN
  42. tcp6 0 0 :::22 :::* LISTEN
  43. tcp6 0 0 ::1:953 :::* LISTEN
  44. tcp6 0 0 :::25 :::* LISTEN
  45. tcp6 0 0 :::993 :::* LISTEN
  46. tcp6 0 0 :::995 :::* LISTEN
  47. tcp6 0 0 127.0.0.1:8005 :::* LISTEN
  48.  
  49. sudo service mysql start
  50.  
  51. service mysql status
  52.  
  53. mysql start/running, process 20757
  54.  
  55. mysql -h 66.123.173.170 -u root -p
  56.  
  57. ERROR 2003 (HY000): Can't connect to MySQL server on '66.123.173.170' (111)
  58.  
  59. mysql -h 127.0.0.1 -u root -p
  60.  
  61. import java.io.IOException;
  62. import java.net.ServerSocket;
  63.  
  64. public class PortMysqlTest {
  65. public static void main(String[] args) {
  66. int port = 3306;
  67.  
  68. ServerSocket ss = null;
  69. try
  70. {
  71. ss = new ServerSocket(port);
  72. ss.setReuseAddress(true);
  73. }
  74. catch (IOException e)
  75. {
  76. System.out.println(e.getMessage());
  77. }
  78.  
  79. long futureTime = System.currentTimeMillis() + 1000 * 60 * 2;
  80. while (System.currentTimeMillis() < futureTime)
  81. {
  82. try {
  83. Thread.sleep(1000);
  84. } catch (InterruptedException e) {
  85. e.printStackTrace();
  86. }
  87. }
  88.  
  89. if (ss != null)
  90. {
  91. try
  92. {
  93. ss.close();
  94. }
  95. catch (IOException e)
  96. {
  97. System.out.println(e.getMessage());
  98. }
  99. }
  100. }
  101.  
  102. sudo service mysql stop
  103.  
  104. /etc/init.d/mysql stop
  105.  
  106. sudo netstat -lpn | grep 3306
  107.  
  108. tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 6736/mysqld
  109.  
  110. kill -9 6736
  111.  
  112. sudo service mysql start
  113.  
  114. sudo /etc/init.d/mysql start
  115.  
  116. telnet 66.123.173.170 3306
  117.  
  118. mysql -h 66.123.173.170 -u root -p
  119.  
  120. bind-address = 0.0.0.0
  121.  
  122. bind-address = *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement