I have a distant web application and DataBase, and I want to do some test in my local machine using the remote Database.
So I changed httpd-xampp.conf -> LocationMatch:
Order deny,allow
#Require local
Allow from ::1 127.0.0.0/8
Allow from xx.xx.xx.xx
And add in my.ini:
skip-name-resolve
Then I restart apache and mysql.
Now I can access to phpmyadmin without problem but not in mysql via command line nor via my web application
How can I remotely access to mysql via command line?
Thank you
Phpmyadmin is not a database. Phpmyadmin is a GUI written in PHP, helping you visually work with your database. The actual database is MySQL. MySQL is running on your remote server, likely, hopefully, behind a firewall. On the same machine is Apache serving phpmyadmin. Apache is accessible to the outside world. Phpmyadmin can access the MySQL database, because it's running locally on the same machine. You cannot connect to the MySQL database from the outside world, because it's behind a firewall and/or doesn't accept random connections from the internet. It has nothing to do with Apache.
And that's good. You should never publicly expose your database to the internet.
The best way to directly connect to a remote database is via an SSH tunnel. For this you need to set up SSH access to your remote system, if you haven't already, and then tunnel using something like ssh -L 9999:localhost:3306 example.com -N. Looks up the specifics in the ssh manual.
Related
Good day,
I have a VB application which i need to connect its database in xampp/mysql..
But mysql/xampp is installed to other computer which is networked at my computer.. What will I do?
The MySql server with XAMPP is no different to any other MySql server , with the exception of the interface; it looks a little bit different. If you want to be able to connect to the server, you need to know the server's internal IP address (you can find it with CMD > ipconfig). The port will generally be assigned to 3306, so you shouldn't have any issues there.
If you want to grant access to the server from your computer, open up the XAMPP control panel (from the other computer) and click Shell. Type in MySql and you'll be able to execute commands, from there (which you can use to grant remote access).
There is a server I wish to connect to. It has multiple VMs running on it each VM has a mysql DB. I can currently connect to this server using ssh and then connect to any of the databases from each VM using mysql -u user -h host -p password. Now I want to connect to the same MySQL DBs using MySQL workbench from my local machine. However there is firewall, currently I use putty to get passed the firewall with public private key authentication and I can access any machine I want. I have seen here that I must install a MySQL server locally ( I've done this I am using mysql workbench) and use the loop-back address, in that way you don't need to access an external server. Could anyone point in the right direction on how to do this?
You need to use ssh tunnelling.
In putty under the options go to Connection->SSH->Tunnels. Add a tunnel from source port 13306 to Destination localhost:3306.
You can do this in Putty either before or after you connect. It's best to do beforehand and save the session configuration otherwise it gets tedious having to re-enter the settings.
In MySQL workbench connect to localhost port 13306.
There is a good guide with screen shots here: Setting up an SSH tunnel with PuTTY
An SSH tunnel makes a TCP port on your SSH client machine and directs any traffic to whatever the destination is set to. You can add multiple tunnels, but each one must listen on a different source port number.
You can forward the port via SSH.
ssh -NL is your friend like so:
ssh -NL 3306:localhost:3306 <yourserver>
Then you can point your workbench at localhost.
You don't need any additional software for this task. MySQL Workbench can create SSH tunnels on its own. Watch my tutorial on Youtube how to create connections: https://www.youtube.com/watch?v=DCgRF4KOYIY.
It essentially comes down to creating the right connection type. There is a drop down that allows you to select an SSH connection. Enter the parameters which you used to connect via Putty.
I am currently programming a launcher in Visual Studio that gets the version history from a MySQL server. I have run into an issue where I cannot connect to the database if I use a public login for the database. If I use the root login I can connect on my local machine but no other. This is what I am using with subins to protect my data:
"server='serverip';user='severusername';password='serverpassword';database'databasename'"
If I use the root password, it will connect on my local computer. If I use my godaddy hosting database, it will also work on any computer. The MySQL server I am connecting to is on my local computer and running WAMP. Does anyone know a way to get it to work? My user has full permissions. This is programmed in Visual Studio using Visual Basic.
It appears that you have a typo:
database'databasename'
Should that not be:
database='databasename'
Also, it could be that godaddy does not allow remote connections for MySQL so when you try to connect from your local WAMP installation to their remote MySQL server the connection is denied. This is more than likely the case as the bandwidth cost for this can become quite huge very quickly. You should however be able to run things in the shared hosting environment using localhost as the server/hostname.
I fixed it by adding 2 cases of my user. One with a host of localhost and another with a host of 127.0.0.1
i am using openshift free tier (3 gears). My scalable app uses PHP and MySQL. But unavailability of phpMyAdmin credentials for 3 gears scalable app it's difficult for me to access Mysql table entries. My question is can port forward feature of Openshift is used to access openshift Mysql via locally installed wamp phpMyAdmin.
Yes, it is possible to use port forwarding to access your OpenShift database from your locally installed PhpMyAdmin.
First, make sure you have the Redhat Client Tools (RHC) installed on your computer. If you haven't, download them here: https://www.openshift.com/developers/rhc-client-tools-install .
In order to connect via SSH, you will need a public/private key pair. Again RHC can automate most of this for you when you run rhc setup. The application will ask for your credentials, optionally create an SSH key for you and upload it to your cartridges. Make sure to protect your SSH key with a secure password. This process is described in more detail at https://www.openshift.com/developers/remote-access .
You will need a SSH client. OpenShift recommends Putty for Windows users; detailed setup instructions can be found at https://www.openshift.com/page/install-and-setup-putty-ssh-client-for-windows . In addition I would recommend to install OpenSSH from Cygwin, as this makes it easier to forward the port to your database later on.
Use Putty and your SSH key to connect to your server via SSH. Once you are at the shell, type env to view a list of environment variables on the server. Look for the variables that end with _DB_HOST, _DB_PORT, _DB_USERNAME and _DB_PASSWORD and make a note of their values on your Windows machine. The names and meanings of all of these environment variables are described at https://access.redhat.com/site/documentation/en-US/OpenShift_Online/2.0/html/User_Guide/Database_Environment_Variables.html .
To forward the port, use Cygwin's ssh command. For example:
ssh -f user#my-app.openshift.com -L 3307:DB_HOST:3306 -N
You will have to replace user with your OpenShift username, my-app.openshift.com with your public OpenShift hostname and DB_HOST with the IP address from the ..._DB_HOST environment variable that you looked up above. If this command succeeds, you should now have a tunnel from your local port 3307 to the MySQL server at OpenShift. Thus, you can create a new database connection in PhpMyAdmin's configuration with 127.0.0.1 as the server, 3307 as the port and your credentials, which you got when running the env command via SSH.
Before you open the session with Putty, go to the Connection-->SSH-->Tunneling.
There add a port, for example, 3333. And set as destination the url of your remote mysql server and port, for example: 324324343455435435-yourservices.rhcloud.com:44351. Click on the "Add" button. Save your session and connect.
Once connected you can use whatever the client and connect to localhost on the port 3333 with the user, password and database name given by the env vars as the other guys said.
I connect with Toad for Mysql with no problems.
You can use the rhc port-forward command, similar to what i described here: OpenShift: How to connect to postgresql from my PC
instead of phpmyadmin.SQLyog from webyog has ssh tunneling option. which work fine for remote accessing openshift mysql
You can add this cartridge to have phpMyAdmin support in scalable apps:
https://github.com/arielscarpinelli/openshift-scalable-phpmyadmin
I have a php application running on XAMPP but I want to connect to a mysql db running on a remote machine(which is also using XAMPP). The application works fine when I connect to the mysqldb instance on my machine. I have changed the configuration files to point to the remote db and have given the correct credentials as well. But I get access denied error.
"Access denied" means you're at least connecting to the remote MySQL instance. Most like you've got a mismatch on the credentials. You may have granted permissions to "user#somehost" on the remote MySQL, but if that machine can't resolve "somehost" via DNS or a Hosts file lookup, it'll have to fall back to checking for a "user#ip.add.re.ss" account.
First I would check the remote database owner / host to make sure they allow external access. Most hosts, especially shared hosting providers, only allow access to scripts run locally and do not allow external access like you are describing.