How to access MySQL from a remote computer (not localhost)?

后端 未结 3 2034
执念已碎
执念已碎 2020-12-04 00:30

I have my dev environment set up as a Ubuntu Server (with LAMP installation) inside a vmware. The vmware is running on my local windows 7 machine. When I try to access my my

3条回答
  •  死守一世寂寞
    2020-12-04 00:57

    first check the ip assigned to vmware using from cmd

    ipconfig/all
    

    suppose ipassigned to vmware is 192.168.11.1 now in vmware in ubuntu check the ipadress

    ifconfig
    

    suppose ip adress of ubuntu is 192.168.11.137 now open mysql configurations

    sudo nano /etc/mysql/my.cnf change the bind address to ubuntu ip address

    bind-address = 192.168.11.137
    

    restart mysql now connect to mysql

    mysql -u root -p
    

    and create a user with all privileges and host ip of vmware i.e 192.168.11.1

    GRANT ALL ON db.* TO user@'192.168.11.1' IDENTIFIED BY 'PASSWORD';
    

    now try to connect from windows. also open port of mysql

    /sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
    

    restart mysql and try to connect on ubuntu host ip address 192.168.11.137

提交回复
热议问题