MYSQL Workbech connection to local network database? - mysql

I'm trying to setup a new connection in MySQL Workbench to MySQL server on my other network computer named say: SERVER
Hostname: SERVER
Port:3306
Username and password I leave blank.
I'm getting "unknown server host"
SERVER has dynamic IP.
How do I provide the correct Hostname?

I don't think that you can connect to a computer of your network with its name only in MySQL Workbench.
So, if you can't allocate a fixed IP with DHCP to your computer running MySQL maybe you could use port forwarding in your router config (localhost:port -> computer2_ip:mysql_port) so you will be able to connect to localhost:port in MySQL Workbench. You could also create a tunnel between the two computer but I think this is rather a question for ServerFault.

Related

Access Lightsail Instance's database with MySQL Workbench

I have an Amazon Lightsail Ubuntu multi WordPress site set up with bitnami stack.
I'm looking for a way to access the Instance's database on Amazon Lightsail with MySQL Workbench remotely.
Please note that I do not have a seperate Lightsail database, as I'm trying to do things as cheaply as possible at the moment. So the following guide is not applicable to me.
Connecting to your MySQL database in Amazon Lightsail
According the wp-config.php MySQL database is using localhost:3306
I have static IP address 3.230.xxx.xxx. I have taken the DB username and password from the wp_config.php file.
I've entered the details.
I wonder if anybody else has managed to connect to an Instance's database, rather than a seperate database.
If this is not possible I wonder if there are any suggestions as how to best access this Instance's database remotely.
Found the answer using a similar youtube video which is used to connect to phpMyAdmin.
https://www.youtube.com/watch?v=9VdcQLDmYII
Basically you need to use Putty SSH tunneling in order to connect to the MySQL instance
First I added a new connection in Putty, make sure port 22 is open on
the LightSail firewall
Go to the Connection -> SSH -> Auth tab on the right hand side menu
Enter your SSH key which is downloaded from the Lightsail dashboard,
it will need to be converted in the standard recognised by putty
Go to Connections -> Data tab on the right hand side menu. Add a new
forwarded port we are forwarding localhost:3306 on the server to a
port on our machine 2222
Start the connection via Putty.
Now in MySQL WorkBench go to the connection to database windows.
Enter the port 2222 I entered the DB user and Password from
wp-config.php file and was able to successfully connect.
Also found a second method
Within the MySQL Workbench you can change the connection method to `Standard TCP/IP over SSH'. Gave the SSH key and the relevant details on connection was accepted
Here is what you need to remotely connect MySQL on Lightsail.
https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-connecting-to-your-mysql-database
There are 3 steps:
get the endpoint link
enable public mode
configure MySQL workbench
Yes I have - after a marathon tech support session with AWS :)
Although the Lightsail firewall may say port 3306 is open, the server instance itself may have its own firewall settings which close it. On my case teh AMI that was used to set up the instance was configured that way
I my case it was Ubuntu but here is the summary of the advice I got from AWS--
We have connected to the instance via SSH using the user-name 'xxxxxx' from terminal.
--
ssh -l xxxxx 34.xxx.xxx.221
Checked and confirmed that mysql is running on the instance.
systemctl status mysql
Confirmed the port on which mysql is running.
netstat -plnae | grep 'pid'
Checked the 'ufw' firewall rules and noticed that 3306 is not allowed.
ufw status
Opened the port 3306 on ufw firewall
ufw allow 3306
After performing these steps you were able to establish connection to your database
hth

cannot connect remotely with online database on localhost phpmyadmin

i have configured the phpmyadmin's config.inc.php file and a drop down menu has appeared accordingly in localhost/phpmyadmin to select the server. But when i try to connect to the server it says:
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
i have added my ip address to the online host server in the cpanel and have access to the remote sql connection.
please help.
Most hosts block incoming connections to the MySQL server as a security measure. You'll have to ask your host about unblocking port 3306 and how to access your MySQL directly -- or run an API on your web host, which would have access to the MySQL server due to being on the same network, and access the database through that. For phpMyAdmin specifically, just install it on your web host instead of your local machine, then access it through the internet rather than localhost.

"Can't connect to MySQL server", only when client is remote server

I'm having a weird problem where I can connect to a certain database server from my local machine (and my friend can also connect to the database server from his local machine) but we can't connect to the database server from his AWS server.
What I get on the AWS server is:
"Can't connect to MySQL server on '<IP address>' ".
It's not as if the database server is only allowing connections from certain IP addresses; it didn't know about my IP address before I tried to connect.
Any idea what could be different about my AWS machine that could be making the connection not work?
Is the MySQL server inside the same network as the local machines? If so, it might explain why local machines can connect but the remote AWS can not.
By default, MySQL disables all remote connections. You can check if the remote connections are enabled. It could also be an issue with port block. MySQL uses port 3306 by default. Either MySQL or the AWS might not be configured to send data through the firewall on port 3306.
Here is a decent article explaining how to open these things up.
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

can cakePHP connect to remote database?

I am setting up CakePHP for the first time in order to develop the server side of the website I'm building. I already have a database set up on a remote server. So I want CakePHP to connect to that server. That's not working. I get a notice "Cake is NOT able to connect to the database."
I've tried changing the settings in cake\app\database.php:
persistent: true or false
host: with or without prefix 'http://'
But none of that helps. All the examples I've seen have server set to 'localhost'.
Can anyone tell me if cakePHP can connect to a remote db? Or am I completely missing the point and should I be using the mysql server included in my WAMP set?
You have 2 options
Option 1
Your webhost needs to allow connections to the mysql instance from outside the local network.
Check the manuals for the webhost if you're allowed to change the mysql configuration yourself you may be allowed to accept incoming connections.
Your method only works when the host accepts incoming connections on for example port 3306 which is the default mysql port.
Option 2
If you have SSH access to the remote host, you're able to set up a tunnel.
Which would make you connect to the Mysql Instance though your SSH connection on a local port.
One way you could do this is by using PuTTY.
How to set up a MySQL tunnel in PuTTY
Initiate the connection and keep it alive.
Use the host 127.0.0.1 and port 3306 in your CakePHP Database config.
Username & Password would be your MySQL User Credentials

Remote mysql database connection

if php uses the following server name mysqlxx.90 and the username ouxxxxxxch to connect successfully to the local database and the server IP is 1x.xx.xx.x8, what would I usually enter as the server name to connect remotely.
Confusing question... I can connect properly to the database through ssh and command line, could it be that I'm just being blocked remotely, and how would I prove this??
Just use the server IP to connect. Obviously, port 3306 will need to be open to connections and your MySQL username and password must be accepted by the server.
You can try
telnet <serverip> 3306
on the command line to see if you can connect to the server on port 3306.