MySQL help wanted
Does anybody here know how to setup a MySQL database for remote access? I can successfully connect to public databases such as 'ensembldb.ensembl.org' and 'mysql-rfam-public.ebi.ac.uk'; what I am now trying to do is to create my own database to which I can connect in the same way.
I have (I think) created the database at my web host, which can be accessed locally (for example from cPanel), but I haven't discovered how to make it accessible remotely via a URL like those above. Any help would be greatly appreciated.
I have (I think) created the database at my web host, which can be accessed locally (for example from cPanel), but I haven't discovered how to make it accessible remotely via a URL like those above. Any help would be greatly appreciated.
0
Comments
-
Check the mysqld.conf file for a "bind-address" directive, comment it out with a # and restart mysqld.
More details here - https://linuxize.com/post/mysql-remote-access/0 -
It's possible your web-hosting provider has a separate collection of database servers, and your database is on a server together with many others, and the machine it's on is not the machine which you use to serve your website. In which case, your provider might have provided a way for you to configure remote access to their database server, or might not. Or it might be public, but you don't presently know the name of the machine.0
-
I see in one of my notes-to-self that at one point, to allow remote access to a hosted database, I needed to "add an access control entry to the remote sql control panel." And to make it work I needed a public DNS name for the IP address I intended to connect from.0
-
Check the mysqld.conf file for a "bind-address" directive, comment it out with a # and restart mysqld.
Where am I likely to find that file (given that this is a shared server, not a local machine to which I have root access)? And is this going to be safe given that there are other MySQL databases which must not be disturbed (specifically those which support bbcbasic.co.uk/forum and lbbooster.com/forum)?
0 -
Is your client failing to authenticate from your remote connection, or is it failing to establish a connection to port 3306?0
-
I needed to "add an access control entry to the remote sql control panel."And to make it work I needed a public DNS name for the IP address I intended to connect from.
0 -
Is your client failing to authenticate from your remote connection, or is it failing to establish a connection to port 3306?0
-
Note that there may not be a remote SQL control panel - a forum I help with migrated from one provider to another and we lost that feature and also lost remote access to SQL, so far as I could tell. A chat with your provider might clarify what's on offer and how to access it. (As I no longer have access to a setup with a remote control panel, I can't say much about how I got access to it, sorry.)0
-
Thinking about it, with quite important content on your DB server, setting up inbound connections to it from the outside world is probably not the most sensible option - one zero-day and it's toast. If I were to set up a static demo DB I would use a dedicated instance, with the content on a read-only volume (e.g. squashfs or a CD ISO9660 image).0
-
If I were to set up a static demo DB I would use a dedicated instance, with the content on a read-only volume (e.g. squashfs or a CD ISO9660 image).
So are you effectively saying that what I am hoping to achieve is impossible? That I can't set up public access to one database without at the same time compromising the two existing databases used for the forums? That seems a surprising limitation.
0 -
In theory it should be fine, but that is making the assumption that no bug exists that could allow a privilege escalation and allow a malicious actor to damage other tables on your server
Demonstrating creating tables and adding content, yes, that makes sense you'd want a read-write setup but for your forums security I would still be suggesting a dedicated instance.
(I'm a sysadmin and it's stuff like this I have to think about every day)0 -
I would still be suggesting a dedicated instance.
0 -
Since you have a static IP, you could set up a small MySQL instance on a Raspberry Pi, if you have an old Pi 1 gathering dust it would do the job, give it an internal static IP and forward port 3306 to it on your router.
Unfortunately I have no experience with these hosting provider control panels, every MySQL/MariaDB server I have built has been on a server, using the command line to set up and administer.0 -
-
I can help build you an SD image if you like.0
-
I can help build you an SD image if you like.1
-
Unfortunately I have no experience with these hosting provider control panels
They didn't express any security concerns but I've currently set it so that it will only accept connections from my static IP address so hopefully that will reduce risks to an acceptable level (unless you consider otherwise).
I may yet want to install a Raspberry Pi server here to provide a database with public access, but the urgency for that is gone so I'll get back to you about that, as and when. Thanks for the help so far.
0 -
I can confirm that my own IP was refused access.
Also, MySQL users can be configured to only be permitted access from specific IPs (or specify 'username'@'%' to allow access from any).0 -
Also, MySQL users can be configured to only be permitted access from specific IPs (or specify 'username'@'%' to allow access from any).0
-
Richard_Russell wrote: »I am now able to connect to bbcbasic.co.uk:3306 (although not yet to the database, but that's likely to be a problem with my BBC BASIC code because I am seeing responses from MySQL).
But with the version of MySQL running at bbcbasic.co.uk it asks to change the authorisation method - to the one I had already assumed! No idea why, but I've modified the BASIC code to accept that response and send the encrypted password again, and now it all works.
As you seem to be something of a MySQL guru (BigEd too), would you care to propose a sequence of operations that I could perform as a test/demonstration that my code, which I intend to release as a BBCSDL library, works properly (I expect it will work in BB4W too).
I'm thinking of something like create a table, populate it with some data, run some queries on it and then delete it.
0 -
Richard_Russell wrote: »As you seem to be something of a MySQL guru (BigEd too), would you care to propose a sequence of operations that I could perform as a test/demonstration
If nobody here is able to help, can you suggest somebody who might?0 -
Since you have a static IP, you could set up a small MySQL instance on a Raspberry Pi, if you have an old Pi 1 gathering dust it would do the job, give it an internal static IP and forward port 3306 to it on your router.0
-
I don't think it should be a security risk, just make sure you're not forwarding anything else in, just port 3306 to your Pi1 (which needs to have an internal static IP, either configured on your router so it's assigned by DHCP, or on the Pi itself.)
If you're making this public, I'd suggest in your code creating a random string, and using CREATE DATABASE <string> so users don't collide with each other on the off-chance more than one runs the demo at the same time. Of course, that means the demo user would have considerable permissions on the database server to be able to do this, another reason for using a dedicated machine so it can't interfere with anything critical.0 -
I don't think it should be a security risk, just make sure you're not forwarding anything else in, just port 3306 to your Pi1
So I have decided not to publicise our static IP address unnecessarily. Instead, for the purposes of demonstration I will rely solely on public MySQL databases. Needless to say they are read-only so I cannot illustrate creating or modifying data, but neither did I in the equivalent demonstration program for BB4W. But they are fine for interrogating the database in various ways.
If somebody was to show an interest in using my new library to create or modify a database (and they have a static IP address) I can add them to the ACL for bbcbasic.co.uk:3306 so they can experiment with that in relative safety.
0 -
Sorry, should have been more clear. Only forwarding 3306 to your Pi, not any other ports to it. Other ports you have for other purposes are fine. (I have lots of ports forwarded).
Also, you don't have to announce the existence of a service on a particular IP for miscreants to find other things, there are constantly scans going on - I reguarly see hits for SSH on not only my machine, but every box at work with a public IP. (Those ones I tend to only configure sshd to listen on the internal private IP. Doesn't stop them from trying though, and where ssh needs to listen on the public IP I disable root login by password.) Another I see a lot of is 5600/udp (SIP), which is awkward as I also have my own VoIP server, so I restrict SIP traffic to the upstreams I use. IAX2, on the other hand, is practically ignored so I use that for my mobile client, also IAX2 is MUCH more NAT-friendly!
But yes, I appreciate your concerns. I also have solar and a CCTV setup.0 -
you don't have to announce the existence of a service on a particular IP for miscreants to find other things, there are constantly scans going onAnother I see a lot of is 5600/udp (SIP), which is awkward as I also have my own VoIP server
0