setup remote sql server - mysql

I've got a small database which is going to be used 1mo/year. I also need a remote access to this database. I have tried dozens of free mysql database servers, but they're all too slow. I mean queries are being executed for ages. For example, it takes 2 mins to execute 10 queries from my Application. What I want is to setup a remote access to my localhost database. I've granted access for '%' IPs, commented bind-address in MySQL config file, but it seems to be working only for local network.
The question is: how do I put my SQL server into the web so anyone could access it using my IP as a host from any location in the world? Is it even possible? At least give me directions how to find an answer. Ty. P.S.: IP is static

Related

Connecting to remote MySQL server without specifying schema

When I connect to my Remote HostGator MySQL server without specifying a database schema, it takes about 30 seconds to connect. If I specify a database schema when connecting, it takes only 1 second. In both cases, subsequent queries work fine and fast.
Doing the same with my localhost MySQL server connects fast regardless.
Does anyone know why the connection is slow when you don't specify a database schema during connect?
Unfortunately, I don't have access to the mysql config.ini file on my shared Hostgator server.
When you are connecting the Mysql server remotely without specifying the database schema, your HostGator MySQL server takes time to lookup for all users / passwords, grants to access resources to all databases and host details etc.
But, when you specifically mentioning the database, it just checks all these things for a single database and works fast.
In case of local system, it does all these things within the milliseconds as there in no any connection with a remote server, no DNS lookup, no bandwidth issue etc. hence it is faster.

Can I use remote database for rackspace cloud server?

We previously had a company setup our website on a web host and they set it up on a rackspace cloud server (unmanaged). It is an expression engine website.
I have now rebuilt the website into Wordpress but cannot figure out how to setup the database on rackspace. There isn't a database setup on rackspace now, so I'm not sure how the EE site is setup.
I am wondering... Is it possible to just load the wordpress files on the Rackspace server, then connect the Wordpress site to a remote mysql database hosted on Hostgator?
If so, does someone know a a tutorial to do this?
I'm clueless when it comes to uploading a database on Rackspace via SSH. I'm familiar with phpmyadmin but not good with unmanaged servers.
Any suggestion what would be the best for my needs? For now, I need to get the site up and running on Rackspace until I can get a managed dedicated or VPS server setup.
*UPDATE*
I have tried to change the DB host in the Wordpress config file to the IP address instead of localhost, but no luck. Any ideas? This is part of the wp-config.php file in the root directory. I have removed the values. I've tried the hostname like this also with no luck... XXX.XXX.XX.XXX:3306
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'remote_DB_name');
/** MySQL database username */
define('DB_USER', 'remote_DB_user');
/** MySQL database password */
define('DB_PASSWORD', 'hiddenpassword');
/** MySQL hostname */
define('DB_HOST', 'XXX.XXX.XX.XXX');
I'm not an expert with Wordpress but it should be possible to have your wordpress site running on a Rackspace Cloud Server connect to a database that is not on Rackspace.
According to http://codex.wordpress.org/Editing_wp-config.php#Configure_Database_Settings, there should be a file named wp-config.php in the base directory of your Wordpress site. You should be able to edit the values of the constants starting with DB_ to configure database connection settings. Specifically, you will want to change the value of the DB_HOST constant to be the hostname or IP address of your database server that is not on Rackspace.
Normally wordpress allows different database server and can connect it with different servers. But here it seems problem is not with connection settings you use. You have to give proper permissions for your IP to the database server.
Please check and add permissions to your IP on database server using your credentials
GRANT ALL PRIVILEGES ON *.* To 'dbusername'#'XXX.XXX.X.XX' IDENTIFIED BY 'dbpassword';
Check these option with your database administrator and try configuration again
Reference :
Wordpress database COnfigurations
While it may or may not be possible to connect to a Hostgator database from a Rackspace server (contact their respective support departments for details), I know one thing for sure: It's a bad idea anyway. Don't do it.
When they're being used for web applications, MySQL database connections are highly sensitive to latency. Each MySQL query performed by your application will be slowed down by at least the round-trip time — for instance, if there is a 10 ms latency between your web server and database server, and your application performs ten MySQL queries for each page load, your page load will take a minimum of 100 ms (10 ms x 10) more than it would without that latency. Ten queries and 10 ms is a best-case scenario, too; many web applications will use considerably more queries than that, and two distant servers may have a round-trip time much higher than 10 ms (100 ms wouldn't be unusual for a transcontinental connection).
Use a local database. If you don't know how to get one on Rackspace, ask their support team!

How exactly am I accessing the host/server through localhost on phpMyAdmin?

I am working on a school project in which I have to upload data onto a database hosted on phpMyAdmin.
What's confusing me right now is that I see "localhost" at the top of the page and before I even query the database I see "Run SQL query/queries on server "localhost":"
Does this mean that I'm hosting a server on my computer and accessing the database through that? Because then I query for "SHOW VARIABLES WHERE Variable_name = 'hostname';" and it returns with hostname = webhost330. (It is hosted on webhost330.asu.edu).
I'm extremely confused about what this means. Thanks for any possible help.
I'm very new to databases so forgive me if I'm missing something simple here.
EDIT: To clarify: I'm not at school, I'm at my house. What kind of implications does this have? In other words, what's the difference between this and hosting a database locally?
When I host a database on my computer through the MySQL command line client, I can create database information and it's stored on my computer in files. Does this mean that it's initially stored on localhost and then that data is used to create files on my computer?
And then the equivalent of that for the webhost330 is that the localhost stores the database initially but then uploads it to the host at phpMyAdmin? That is the primary thing I'm confused about.
This exactly means what you assumed. When connected to localhost, you are connected to local MySQL server on same machine. Using webhost330.... you are connected to that remote MySQL server instance, if that is not the name of your own machine. Your own server can be webhost30.etcetc.
Edit
If your website is hosted here: webhost330.asu.edu then MySQL host either being webhost330.asu.edu or localhost both mean the same local MySQL server on your very machine.
Edit based on your update
If you are at home, then localhost means you are connected to a MySQL server that you have installed on your own computer. and webhost30.etc.etc means you are connected to the database you have at your school. Database do allow remote connectivity and if you are connected to school from home, that's a remote MySQL connection.
To remove your confusion, you should use only localhost in your code. localhost at home will mean the development server which is your home computer, and when you take the same code to webhost30.etc.etc then localhost for that server will mean its own MySQL installation. So localhost will work everywhere as long as you don't want your code to connect to a remote external MySQL database server.
Assuming you're at school, and assuming you're on your school network. Then yes, your machine is probably "webhost330.asu.edu". At the very least webhost330.asu.edu thinks "webhost330.asu.edu" is localhost.
To see what "localhost" refers to in terms of MySQL server, you have to look at the URL you are using to connect to the web server.
For example, if the URL is
http://localhost/phpmyadmin
and this instance of phpMyAdmin tells me that the MySQL server is on localhost, this means that the MySQL server is on my local workstation.
If the URL is http://example.com/phpmyadmin, then localhost will mean that the MySQL server is on the same machine (example.com).

Allowing Remote MySQL connections

I'm building an Excel app using VSTO / VB.NET and make several connections to a bunch of databases/tables in MySQL which is hosted on a BlueHost account.
Now, they require for the IP address of the inquiring computer to be registered as a 'host', which sounds great for security but given the app will be distributed to a theoretically unlimited number of people on an unlimited number of computers - it's very impractical for me to individually allow each client IP address in my BlueHost account. What's the best way to allow access, on the fly?
The database user/password will already have the correct permissions to the relevant databases etc. It's just a matter of allowing them access to a remote MYSQL connection to start off with.
I've read around SO to use the 'GRANT ALL' SQL Command but I'm not sure exactly when and where to use this. How would you run a SQL command before making a connection to the database; because it is at this point that the connection throws an error..
Take a look at this it has all your info for conecting to remote servers too, Here

Block all users except localhost from phpmyadmin and mysql

I recently installed the XAMPP stack on a desktop and connected via a laptop on the local network. To my surprise, I was able to access phpmyadmin and delete update all mysql tables. Though I understand that I shouldn't use xampp for production (and I'm not), I would still like to learn how to manage these types of obvious security flaws. I know that I can block access to directories via .htacces (http://forum.directadmin.com/showthread.php?t=29089), but I would like something that is a little more comprehensive. How would you restrict running of mysql queries from anywhere except localhost? Is there a way without .htaccess? I thought this was partially the purpose of the root user.
MySQL defined users with domains. If you look at your user_privileges table in the information_schema database you will see that they all have domains. If all your users are defined strictly as localhost, there will be no remote access.
Also, you can edit my.cnf to turn off tcp access to the database, forcing all connections to be by socket. under [mysqld], include the line skip-networking. You will have to configure all your apps to use the socket connection, but I like the socket better anyway.
This will do nothing to protect your data from someone using phpMyAdmin, if phpMyAdmin is installed on the same machine as the database. The safest thing to do is get rid of that app. That's often not practical, however, as it's a useful tool, and so you need to configure phpMyAdmin to require that users authenticate themselves. That means NOT putting the password in the config file. You will need to think about how long sessions are before reauthentication, and things like that.
phpMyAdmin fills me with a rage hotter than a thousand suns whenever I try to configure it, but it is definitely possible to set things up so a password is required each time you connect to the database through phpMyAdmin. You can further limit the damage phpMyAdmin abusers can do my making sure it only connects as a user with limited privileges (for instance, only able to modify the database you're working on at the moment).