Configuring MySQL with Node.js from AMP project - php

I am trying to migrate an existing MySQL + PHP project (with phpMyAdmin) to server-side javascript (Node.js and Express). I am wondering how best to establish a MySQL connection with Node, given that the current setup is on phpMyAdmin? That is, is it possible to configure the node-mysql connection such that it finds the host on phpMyAdmin?
In case the above is not possible, I would like to allow collaborators access to this database. Setting up remote MySQL connections to my localhost MySQL database seems to be one solution, but I have run into difficulty in following this post for two reasons: How to allow remote connection to mysql.
An /etc/mysql folder does not exist on my system (cannot find my.cnf)
Upon granting remote access, I'm unsure how to specify the host and/or ip address for other users that will be connecting remotely to my localhost MySQL db.

Related

MySQL database access without hostname via PHP

I'm doing this for a couple of years now but I haven't faced anything like this. I'm renting a webserver which has MySQL storage. For security reasons the hosting company refused to give me a host name to connect to the MySQL server from a php script. The reason was that there is an IP filter on he server and one can only connect to it with a whitelisted ip. Is there any solution for this situation like a server sided proxy? Also I do have access to the MySQL server via phpMyadmin.
I did some research and I've found that Navicat has proxy support. Altough it's not free.
Based on your description, it sounds like you have a server with MySQL, PHP and phpMyAdmin all running on the same server. If that's the case then typically the hostname for MySQL will be "localhost", possibly with a port or other code added. It is quite common for web hosting companies to not allow remote MySQL access, though the good ones will have it off by default and let you turn it on either for specific IPs (best) or for "everywhere".
When you are logged into phpMyAdmin, take a look at the very top of the main window and you should see something like Server: localhost or Server: www.example.com:3306 - that is your hostname for any MySQL access, provided the PHP code is running on the same server as phpMyAdmin.
If you actually need to run a program on a different server and access that MySQL database then you are probably out of luck.

How to access external MySQL from within Vagrant?

I would like to access a MySQL database in the public network my host is on.
I need to access the MySQL database from within Vagrant by connecting to the DB via PHP's mysql_connect.
I have an ubuntu/trusty64 Vagrant box running Apache2, PHP and MySQL through the old mysql extension.
When I try to connect to the database on the network via the DB server's IP address, it says Can't connect to database.
What do I need to do to be able to access external servers from within the Vagrant guest?
I could connect properly after all. I just mixed up the variables for my password and the DB name in my code. ^_^;

include mysql connection remotely php

I know how to connect to a MySQL DB on a remote server. What I want to do is, connect to the remote mysql server on the clients site without them being able to see my connection credentials by simply downloading the sqlconnect.php file.
the reason for this is because I have built multiple sites that are almost identical. they are essentially re-seller sites. I built it in a way that one database handles all the sites and simple "site ID's" passed on by each site determine the content delivered.
I need to connect to Mysql remotely but dont want to leave the connection file on each persons server. I'm not so much interested in protecting the rest of the code, just the mysql connection credentials itself.

How to setup Windows Server 2008 for MySQL remote database connectivity?

I am very new to this server setup and database connectivity. I googled a lot but couldn't find the solution for it.I am developing an android application which needs to post data to remote database. Which is done.
Now i have to setup MySQL Database in the new Windows Server 2008. I have installed and managed to get access the root user(Which is fine). Now i want to access this database from my local computer[Which is iMac]. I already set the privileges by following this link. When i tried to run from my web application it shows the following error.
Error: unable to connect to database. Host 'xx.xx.xxx.x' is not allowed to connect to this MySQL server
Here is my questions
1.) How to get access to the remote MySQL database from any computer?
2.) How to run the web application in the server?Like Web Hosting i.e Do i need to setup ftp account and put the stuff over there?(For Eg: testhost.com/connecttodatabase.php by executing this it will execute whatever code in testhost server. But i have no idea how to do that for my server).
Any help is much appreciated.
Alternately, You can also try...
use the_database_name;
GRANT ALL PRIVILEGES ON
the_database_name.*
TO
'the_user_in_php_code'#'%'
IDENTIFIED BY
'password_of_the_user_in_php_code';
FLUSH PRIVILEGES;
source:
http://forums.devshed.com/mysql-help-4/host-is-not-allowed-to-connect-to-this-mysql-server-366908.html

How can I connect to MySQL database on a dedicated Windows 2003 server from EC2 based app server with PHP

I have developed a web application that uses PHP and MySQL and has all been running fine from a single development server. I now want to separate things a bit and place an app server within Amazons cloud that will receive and process uploaded files. The database is going to remain on the dedicated server but will need to be accessed by the EC2 instance.
Heres what I have tried so far...
In phpMyAdmin I added a new user to the privileges table. I gave it the elastic IP address from AWS as the host name, a new password and granted privileges to INSERT, SELECT and UPDATE.
In the PHP scripts on my EC2 based app server I included this username, password and the domain name of the location of the mysql server (example.domain.net) when connecting with mysql_connect
I have a simple test page that tries to SELECT and echo some results from the database but get the following error -
Could not connect to MySQL: Can't connect to MySQL server on 'example.domain.net' (4)
What could this mean, what have I missed, are there any other issues such as trying to do this from within EC2 that will cause other problems?
cheers all
Turns out the only other thing I needed to do was to open port 3306 on the database server to allow access. Did this by going to Control Panel -> Windows Firewall -> Exceptions -> Add Port ["SQL", 3306]
Now it works great!

Categories