Header Ads

การตั้งค่า Mysql ให้ใช้ remote accessได้ สำหรับ Ubuntu Server 16.04


 

1.ทำการเปิดไฟล์Config ของ mysql  
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
2.ค้นหาบรรทัดที่เป็น bind-address= 127.0.0.1
bind-address            = 127.0.0.1
3.ทำการแก้ไขใหม่เป็น bind-address = 0.0.0.0
bind-address            = 0.0.0.0





How to Allow MySQL Remote Access in Ubuntu Server 16.04
4.หลังจากนั้นทำการ Restart Service
systemctl restart mysql.service
ตอนนี้เราสามารถใช้ remote access ได้แล้วแต่เราต้องไปเพิ่มสิทธิ์การเข้าถึงของ User ก่อน 
  ทำการสร้าง User ใหม่โดยเข้าถึงได้ทุก IP
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
  หรือสร้าง User ใหม่โดยเข้าถึงได้แค่ IP ที่เรากำหนดเท่านั้น
CREATE USER 'username'@'192.168.1.100' IDENTIFIED BY 'password';

  5.ปิดfirewall

sudo ufw allow 3306/tcp
sudo service ufw restart



  6.ทำการตรวจสอบ

netstat -tulnp | grep mysql
  หากมีผลลัพธ์เป็น socket 0 0.0.0.0:3306  จากอันเดิมที่เป็น 127.0.0.1:3306.




MySQL Server running on the socket 0 0.0.0.0:3306
  เพียงเท่านี้คุณก็สามารถ Remote โดยการใช้ port 3306   
telnet 192.168.1.10 3306
  

1 ความคิดเห็น:

ขับเคลื่อนโดย Blogger.