Can Putty Connect To Remote DB and Open PhpMyAdmin? - mysql

mostly likely a dumb question as I know PhpMyAdmin is a browser-based application and typically putty connects to MySql via command line.
I typically manage my dbs direcrtly via PhpMyAdmin and am wondering if through Putty I can open PhpMyAdmin or perhaps create a tunnel that will allow me to access through a physical UI.
Might be a shot in the dark here but if someone could help spoon feed me an answer on this I would very much appreciate the guidance. Not finding many useful resources online.

In PuTTY you can add tunnels to an open SSH connection by clicking the icon in the upper left of the PuTTY terminal sesssion and selecting change settings. In the Category tree select Connection->SSH->Tunnels. Add a new Tunnel by filling in an unused local port number such as 8880 and a destination of localhost:8080 and click add. If necessary change the destination port to the one your PhpMyAdmin listens on.
Now you should be able navigate to the PhpMyAdmin on the remote machine by navigating to your local machines port 8880 by entering localhost:8880 (or whatever local port number you used) into your browser.

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.

Unable to run Xdebug in PhpStorm, connections are refused - likely due to port 9000 not being open or not being forwarded

I'm trying to debug my PHP code running on a remote server using PhpStorm's Xdebug feature. A few weeks ago I was able to do this on another computer, but I no longer have that computer. I reinstalled and configured PhpStorm and can run SFTP and SSH with the remote server on the new computer. I tried using PuTTY, and was successfully able to use it to SSH Tunnel between the two computers and run Xdebug. But it wasn't a 'good' as the way I was able to do this on the other computer, which didn't need PuTTY.
I believe that the problem has to do with setting up Port-9000 forwarding. I added a rule for this to my BitDefender BOX2 for the local computer I develop on, but I still get refused. The tech at BitDefender thought that there may be another port that needs to be opened/forwarded in addition to port 9000.
Because the PuTTY method works on the new computer, I'm confused. Why does this work with PuTTY, but not directly with PhpStorm (without the help of PuTTY)?
Xdebug only needs port 9000, so that is the only port that PhpStorm will listen on, and Xdebug needs to connect to. I don't know BitDefender, but perhaps you only allowed outgoing connections, and not the incoming ones that you should allow?
Are the two machines on the same network, or is your machine behind a NAT network to the outside world, where your remote machine lives? In that case, you probably can't get around using your SSH tunnel with PuTTY.
You don't mention any settings, but it is worthwhile to check what shows up in the xdebug log file (when configured with xdebug.remote_log=/tmp/xdebug.log on your remote machine). It will show what Xdebug tries to connect to, and whether (and sometimes even why) the connection failed.

Using SSH tunnel to connect to remote MYSQL database from Node-Red

I have a set of data rolling out of Node-Red that I want to send to a remote MYSQL database. The Node-Red system is running on a Raspberry Pi. How do I make this work? I know how to it using Node.JS but im not sure how to do this in Node-Red. The IP-adress of the Pi is dynamic so simply authorizing its Ip address does not work sadly.
Thanks in advance!
EDIT for clarification:
I want to connect to a remote MYSQL database that is hosted by my webhosting. I have connected a Raspberry Pi to a battery, and I want to save this information in the aforementioned database. Since there will be several battery setups in different locations, I cannot save the data locally. So, one way or another I need to access the remote database through Node-Red. Authorizing one IP-address does't work, since the IP of the Raspberry Pi network is dynamic and thus changes. I think a SSH-Tunnel might be the solution, but I have no idea how to this in Node-Red, and google isnt very helpful.
OK, so as I said in the comments you can make a Username/Password pair for MySQL can be granted permission to any IP address (which is less secure if the username/password is compromised. Set the host to '%' to allow all hosts when setting up the grant options).
To reduce the risk you can restrict the Username/Password to a specific subnet. This could be a wifi network or the subnet associated to the piblic IP (it needs to be the public range as nearly all cellular ISPs use CGNAT) range of the cellular provider you may be using. (See this question for details How to grant remote access to MySQL for a whole subnet?).
If you want to use a SSH tunnel then this will normally be done outside Node-RED with the ssh command line e.g.
ssh -L localhost:3306:localhost:3306 remote.host.com
Then configure the Node-RED MySQL node to point to localhost.
Since the connection will look like it's coming from localhost on the MySQL machine you need make sure the Username/Password is locked down to a that host.
You will probably also want to set up public/private key authentication for the ssh connection.
You may be able to run the ssh command in the node-red-daemon node, which should restart the connection if it gets dropped.

Login to EC2 server to create MySQL database

I had a friend create an AWS account and an EC2 instance after which he gave me the username and password to login. I am having a lot of trouble getting into the server with the information he gave me. I'm new to amazon services so I'm not sure if I'm doing something wrong or not. I seem to be able to login using PuTTy, but it doesn't prompt me for a password, I just get through with the username alone. copying the ip into a browser just gets me a "This webpage is not available"
message. He also gave me the key file but I'm sure where to use it.
Anyone know how I can get into the server to modify the database?
If there is a message 'This webpage is not available' then it could be there is no HTTP server running on port 80, or the security group configured on the EC2 instance is set to deny connections to port 80. If it is a new instance, there probably isn't a firewall configured locally to deny connections.
If you are sure there is a server running on port 80, you can use these instructions to tunnel through SSH
Set up your PuTTY window like this, and hit the Add button
Navigate to http://127.0.0.1 and you should see the web server if there is one running, if you can navigate using this way, you have a problem with your security group configuration. If you cannot, you do not have a HTTP server running to connect to. If there is not one running (and I am assuming you wish to use phpMyAdmin), you may have to set up apache and install phpMyAdmin
As you connect without a password, do you receive a line along the lines of
'Authenticating with public key "unipc-rpi"' or mentioning 'Pageant', because it means that instead of a password, PuTTY is authenticating using a public key and not a password.

No sql server database connection with localy used IIS

i am trying to get a database connection through my IIS with an MVC Webproject.
In my Web.conf connection string i use following parameters:
data source=[Computername]\[DatabaseInstanceName]
This doesn't work for me.But when change the [Computername] to my IP-Adress it works.
Somebody with an idea what i can do? Because it's annoying to change this everyday in several files.
edit: i am using the IIS 8
There are several ways I verify my connection
1) If you are using visual studio,
a) on the Data menu click on Transact-SQL Editor and check this dialog
b) Another trick is I try to create a datasource, follow the dialog box and copy the connection string that Visual Studio generate
c) If look at the Server Explorer and you can find your database there, right click the database and click Properties
The computername needs to be accessible to the machine. Currently only the IP address works because nothing is telling the system that myComputerName is the machine located at the IP address.
You can either add an entry to your hosts file or to a local DNS server if one is used. If adding to your hosts file (it'll be somewhere like C:\Windows\System32\drivers\etc) and you'll need run your text editor as an Administrator. The entry will look something like this:
192.168.1.1 JSCWorkstation
(obviously change the IP and computer name to your actual values. If the database is running on the same machine as the application you can use the local loopback address (127.0.0.1) as the IP for the entry.
If you are in an environment with a local DNS server you can ask an administrator to add a similar entry in the DNS server.
Once this is done your machine can be found by name rather than by IP address. You can test by opening up a command prompt and typing
ping myComputername. If you get a reply, all is well.