Windows XP localhost as MySQL server alias - mysql

I'm on the road at the moment and just had a thought
I have a Windows XP Virtual Machine installed with Delphi and a local MySQL server set up with copies of the "live" databases back in the office.
I'd like to be able to use the local db in place of the "live" one if I'm offline.
At the moment in Delphi I have "local" connections set up, but these are only any use within Delphi. And often lead to issues if I forget to switch back to the live connection when I get back to the office.
Is there any way I can fool Windows into thinking that the local MySQL server is in fact the office server if it can't reach the office server? Can it spoof two server names?

You can edit the hosts file in c:\windows\system32\drivers\etc\hosts which will allow you to make any requests to server.fqdn go to 127.0.0.1
http://kb.simplywebhosting.com/idx/0/045/article/
e.g. a request to servername.domain.tld using MySQL connection strings will redirect to your local DB.
You will still need to remember to change this back when you get to the office...
(If you have delphi on the laptop though, why not create a simple service which edits the hosts file based upon whether the server is reachable or not.)

Related

Finding MySQL localhost URL and/or accessing phpmyadmin

Going around in circles. Please help, I enter http://localhost into safari on my mac and receive: It works!
However, I cannot figure out how using MySQL workbench I can find the URL. I am looking to code JSON in xCode to retrieve data from my local MySQL database, however, I do not even know the URL to access it.
My port is on 3306. I have tried http://127.0.0.1:3306 - and get a failed to open.
Do I need myphpadmin or can I go direct to MySQL?
I have tried saving a copy of MyPhPAdmin under Users>MyUserName> but this did not work when I ran: http://localhost/myphpadmin
Should the file be saved elsewhere? When I worked on Python weeks ago I run it under a different location then was recommended (Under the Python X.X cache folder) whereas online people simply ran it from their Users>MyUserName> folder. I am on the latest Catalina OS X.
Tried http://localhost/usr/local/mysql-8.0.20-macos10.15-x86_64/phpmyadmin/ - 404 not found
With MySQL, you can connect via localhost "socket" or networking "TCP/IP" connections. The user accounts in MySQL exist separately from each other, so if your user account exists with host value 'localhost' the TCP/IP connection probably won't work for you. Also note that, depending on how you installed MySQL and how it's configured, it might not even listen for network connections. Normally, localhost is preferred if you are on the same machine.
In MySQL Workbench, you need to give the hostname or IP address when selecting "Standard (TCP/IP)" from the "Connection Method" dropdown. This is simply the hostname or IP address, not a complete URL or web site. So you'd set the hostname to "127.0.0.1" or "192.168.9.34" or whatever. Again, Local Socket/Pipe is usually a better choice in most cases.
MySQL uses its own networking port (3306) and communication protocol, so using http://127.0.0.1 is incorrect as it isn't using the http protocol. Likewise, if you would need to change the port for some reason, specify that in the port field rather than as a part of the hostname.
As for phpMyAdmin, you would install that to a folder that is handled by your web server, then access it through the URL/path exposed by the web server — by default, your user home directory is not shared to the web (and rightly so, I don't want all of my documents and files shared with the world!). Put the phpMyAdmin folder in your web root and you'll have better success. Which folder that is probably depends a lot on which webserver you are running, how it is installed, and how you configured it.
I won't comment on the Python scripts you've run in the past, as my experience with serving Python to the web requires adjusting some settings in my nginx configuration and I won't want to confuse you compared to the tutorials you're following.

Wordpress: MySQL Database and UNC Share

I am about to install WordPress on a Windows 2008 server - two load balanced servers with a UNC share. Web browsing using the server is out of the question (IT security policy) so using the Microsoft Web Platform Installer is also a non starter. I will therefore have to install it manually.
So far I have installed PHP (routine), but I now need to install MySQL and create a database. However, with these being two separate servers, what effect is this going to have on the database - will this require a database on each server? Will they remain in sync? Can the database itself be put in the UNC share?
In short, can anyone advise me whether this is possible and how to go about it?
Thanks
Install MySQL and create the database on the server which is supposed to have it - preferably a 3rd one or on the UNC. In the MySQL config, enable network connections via my.cnf, specifically the bind-address.
Both the PHP boxes should connect to that one MySQL db (using it's LAN ip address). (And yes, they would remain in sync since they connect to the same db.)

Push sensor data from raspberry pi to local host phpmyadmin database

I would like to push sensor data from the raspberry pi to localhost phpmyadmin. I understand that I can install the mysql and phpmyadmin on the raspberry pi itself. But what I want is to access my local machine's database in phpmyadmin from the raspberry pi. Would it be possible?
Well, from what I understand, you'd like to save the sensor data arriving in your Raspberry Pi to a database and access it from another machine. What I suggest is, install a mysql db instance and phpmyadmin in your Raspberry Pi and you can access phpmyadmin from another machine in the network by using the RPi's ip address.
Hope this is what you wanted to do.
Sure, as long as they're on the same network and you have granted proper permission, all you have to do is use the proper hostname or IP address of the MySQL server (what you call the local machine). In whatever utility or custom script you have that writes data, use the networked IP address instead of 127.0.0.1 or localhost for the database host.
Depending on how you've installed MySQL, you may not have a user that listens for non-local connections, incoming MySQL connections may be blocked at the firewall, or your MySQL server may not listen for incoming network connections.
You've asked about using phpMyAdmin from the Pi, accessing your other computer, which doesn't seem to make much sense to me (I'd think you'd want to run phpMyAdmin on your desktop computer, not a Pi), but if you've got a GUI and compatible web browser running on the Pi then you'd just have phpMyAdmin and the webserver run on the same desktop computer that has MySQL and access that hostname and folder from the Pi (such as http://192.0.2.15/phpmyadmin).
If you're planning to make the MySQL server itself public-facing, you should really re-think that decision unless you know why that's a bad idea and how to properly secure it (but that may not be a concern; for instance I have one at home that is available on the local network, but my router blocks any incoming connections from external sources).

How do I connect VS2010 to a MySQL database (locallay on another computer)?

I have a MySQL database on another windows computer (a server) that is setup locally using remote desktop connection for testing.
How can I connect to that local database to Visual Studio 2010 on "my computer"?
Server Computer(MySQL database setup local) --> My Computer(Visual Studio for test code..)
I am new to MySQL and any suggestions will help.
Thanks
PS: I have found this, but the "Server Name" for the database is 127.0.0.1 which I can't use because it is local on whatever computer you are on.
http://geekswithblogs.net/mbridge/archive/2010/12/13/visual-studio-2010-hosting--connect-to-mysql-database-from.aspx
You'll have to use the address of the computer that it is hosted on. It should be the same as the address you use to connect to the remote desktop session.
You might need to configure the firewall to accept the connection. You also might need to setup MySQL to allow remote connections with the user that you authenticate with.
I would recommend downloading MySQL workbench and install it on your local computer. Once you get the connection working with that, you should be able to use the connection with VS2010.
If you're not sure how to do the things listed above, you'll need to start out with a basic tutorial on setting up MySQL for remote connectivity.

Secure Remote mySQL Connection

Since our shared hosting server doesn't allow us to setup Tomcat I decided to install it on our local machine. The local Tomcat server allows us to listen to a certain port for Bancnet transactions which will then be processed and written to the remote site.
Question:
Is it safe for me to set the local PHP application to connect directly to the remote mySQL server? Any suggestions on how to make the connection secure. BTW, I have a self-signed certificate installed in the localhost but not sure how this applies to remote mySQL connection.
You could create a ssh tunnel between MySQL server and client. For more resiliency, use autossh.
If you don't connect over SSL or some other encrypted tunnel, I would absolutely assume that anything you send or receive from MySQL is done so in clear text that can be intercepted and used for malicious purposes from any link along the way. This might be fine for testing purposes with dummy data, but before you put this in production use or pull down live user data for testing, you really should either make arrangements for the data to be stored local to the web app or for there to be an encrypted connection.
Giving you a full overview of how to set up SSL connections to MySQL is beyond the scope of Stack Overflow and it's a bit complicated, but if you want to proceed, check out the documentation and do some research, there are some good informational resources out there.
I'm a bit confused as to the architecture you are trying to describe. What's running where?
If you can't install Tomcat then you probably won't be able to install anything like VPN software on the box.
MySQL can encrypt using SSL provided it has been enabled at compile time and at run time.
Alternatively, it should be fairly trivial to build a webservices tier on top of the remote database.
I would recommend switching to a VPS or managed host though.