Allow remote access MySQL, Ubuntu

前端 未结 3 864
北恋
北恋 2020-12-21 10:27

Im trying to allow remote accecss to MySQL on my Ubuntu server (VPS).

Im trying to access the database through an Java application Im building in Netbeans. Netbeans

相关标签:
3条回答
  • 2020-12-21 10:57

    Change

    bind-address = 127.0.0.1
    

    To

    bind-address = YOUR-IP-ADDRESS*
    
    0 讨论(0)
  • 2020-12-21 11:00

    You need to grant access to that database :

    GRANT ALL ON foo.* TO bar@xxx.xxx.xxx.xxx IDENTIFIED BY 'PASSWORD';
    

    And also updated the firewall rules something like :

    /sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
    
    0 讨论(0)
  • 2020-12-21 11:15

    if you want to use Connect via PuTTY and tunnel
    look at the bottom of this answer


    I assume you have a mysql administration tool.
    The following will look depending on the tool used linux or something else, but work the same.

    Login there and go into the user administration.

    enter image description here

    If you have installation a normal Mysql, then there should be only root without a host.

    From the moment when you have created a localhost, then Mysql assume that you want to manage multiple hosts.

    enter image description here

    Create a existing host. A computer name exists in your network. Here root@dxxxxx-p. This should be created under the root user.

    That's not all now you still have all your tables grant permissions.
    Here pricelist has no assigned permissions

    enter image description here

    But sample has all permissions

    enter image description here

    With multiple host administration is for example.

    A computer with two accessible names

    • myComp1 : IP 192.168.0.101
    • localhost : IP 127.0.0.1

    If you now connect on the same computer with "mysql -h localhost -u root ...." you get the permissions you have assigned to localhost.

    You might think because localhost and myComp1 is the same computer.
    Now automatically myComp1 has the same permission as localhost .
    But this is not so. So be careful.

    Connect via `PuTTY` and tunnel

    when you connect you with PuTTY, everything described above is not necessary.

    With tunnel you connect as root@localhost on the ubuntu server.

    Localhost is here somewhat misleading because it does not relate to your windows computer but on the localhost on the ubuntu server.

    Access Your MySQL Server Remotely Over SSH

    So you’ve got MySQL on your web server, but it’s only opened to local ports by default for security reasons.

    If you want to access your database from a client tool like the MySQL Query Browser or Netbeans , normally you’d have to open up access from your local IP address… but that’s not nearly as secure.

    So instead, we’ll just use port-forwarding through an SSH tunnel, so your MySQL client thinks it’s connecting to your localhost machine, but it’s really connecting to the other server through the tunnel.

    enter image description here

    Go to SSH->Tunnels

    enter image description here

    After clicked Save

    Make sure that the MySQL server are off on the Windows computer.
    I'm using MySQL System Tray Monitor.

    With a right click, I see all the options.

    enter image description here

    click Open

    enter image description here

    If you have done all the settings for SSH on ubuntu right, that should appear here. (If NOT Search for Ubuntu SSH and Putty on the web)

    enter image description here

    Do not forget: Now that you've logged on ubuntu server you have all the right as root@localhost on the server itself, since root@localhost has all rights, you need not create a host and create permissions to schemas

    enter image description here

    Now on your windows computer open MySql Query Browser

    enter image description here

    Now connect to localhost (remember this localhost means localhost on ubuntu)
    You can use in Netbeans the same settings to connect to Mysql on Ubuntu

    enter image description here

    Mysql Query Browser opens you can work on your Databases on UBUNTU

    enter image description here

    Netbeans

    enter image description here

    After closing New Connection Wizard
    A new connection is created with all Databases On Mysql Ubuntu.

    enter image description here

    0 讨论(0)
提交回复
热议问题