I have written some code and am currently running it using loachost however am trying to set it up so that I can run the app from other computers, I am using MySql and after searching online I found that if I replace "localhost" with my IP address (found from google) for the host name on MySql I will be able to connect from other machines, I tried this and got an error saying that I cannot connect to the server and listed some checks:
Check that MySql is running on the servr - how do I check this?
Check that MySql is running on port 3306 - I changed this to 3307 when making the database however, I tried both and got the same errors.
Check if root has rights to the IP address from your address - I am running this from the same computer and it has worked fine with localhost so I dont know why it wouldnt but how would I check this?
Make sure you are providing password - I did when I tried to connect to the database and got this error.
Could someone please help me, I have been searching for hours and cant find how to fix this.
You need to grant access to the account root#%.
root#localhost and root#% are two different accounts. When you're using localhost as the hostname, and specify user name root, you use root#localhost.
When connecting using an external IP, you need to grant database access for root#%.
Related
I have created 2 Ubuntu 20.04 VMs using VirtualBox. I have a Django App on one VM and MySQL DB on the other VM. How do I access the MySQL DB using the first VM?
I used the inet from the output of ifconfig for the IP Address
What I tried:
On the VM having MySQL DB:
-> Change the 'bind_adress' field to '0.0.0.0' in '/etc/mysql/mysql.conf.d/mysqld.cnf'
-> Created a new user using CREATE USER 'test'#'IP_Address1' IDENTIFIED BY 'password';
-> Ran "sudo ufw allow from IP_Address1 to any port 3306"
On the VM having the Django App:
-> Tried to connect to the Virtual Machine using mysql -u 'test' -h 'IP_ADDRESS2' -p
The error I'm getting:
"Unknown MySQL host 'address'"
PS:
I created a NAT network on VirtualBox using File->Preference->Network and attached both the VMs to the network and set Promiscuous Mode to "Allow All"
How or where are you defining IP_Address1 and IP_ADDRESS2?
Specifically, your DB machine needs to know what the IP address of the client machine is when you use your CREATE USER query. So, IP_Address1 must be "known" to that machine. Maybe you just hid the IP address when you posted the question, but it might be easier to use actual IP addresses in both cases until you get connectivity.
For example, if your DB machine is 172.18.1.1 and your client machine is 172.18.1.2, then you should use those IP addresses in your commands listed above
Created a new user using
"CREATE USER 'test'#'172.18.1.2' IDENTIFIED BY 'password';"
...here you're defining the IP address of the client connection.
Then in the client machine:
"mysql -u 'test' -h '172.18.1.1' -p"
...here, telling the client the IP address of the DB machine
More importantly, you might also have to expose the DB to the local network in its configuration settings. You'll also have to deal with any routing issues if the two machines are not on the same local subnet.
There are several articles describing how to configure MySQL for network access, such as: https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql
What have you tried? Can you connect from the command line on the .5 machine? There's a mysql command line tool you can use to connect, which might give you some more information, or have you looked at the MySQL logs to see what it's unhappy about?
It could be something like a permissions issue for the user - creating a user alone is not enough to allow them access to database resources. Maybe try something like:
GRANT ALL ON Database.* TO test#'172.25.1.5' IDENTIFIED BY 'PASSWORD';
I was assuming you had configured the various permissions on the database and were only seeing connectivity issues, but from your responses, it's not clear.
Basically, you need to isolate whether the problem is a user permission issue, an IP restriction issue, a VM issue, a coding issue with your app or something else.
Please provide more feedback about what you've tried if you're still struggling, but this could be one of a number of issues.
I can't connect remotely from Nodejs to a MySQL database from a domain. I've searched a lot, my ip is listed in the host list, and I've also checked the MySQL variables and the bind-address is set to *.
And, also, does anyone know why when I try to add a new host for remote mysql connections it says that the % wildcard is not allowed?
With another domain it works just fine.
Please help me figure it out.
Thanks!
You need to check if the port is open from remote by using MySQL workbench or other clients. You can also use telnet in the command line:
telnet {database ip} 3306
If you got a timeout, It seems there is a Firewall or Mysql config not listening remote IPs so call your ISP or hosting provider and ask them for open access.
But if you got "access denied" message or telnet connection was successful, we have something wrong in MySQL user privilege.
I'm currently trying to run an application on a server but my customer is very 'picky' about their data and wish to store the database on their own internal office server. I've installed MySQL and can get the application to run locally but for a few specific reasons the application needs to run else where.
I basically can't get access to MySQL from a different location. I think my main stumbling block is port forwarding to the correct location. MySQL is installed on a mac mini with local IP address 192.168.1.242 and the router/modem is an Apple Time Capsule. I've tried looking at tutorials but they all have options that I don't have access to. I've attached a screenshot of the options I have access to and the settings I've tried so far.
Other information possibly needed is:
I need to connect from PHP
I've set a user up within MySQL with a wildcard (%)
I'm testing it using the following: command on my local machine in CMD: mysql -u username -h remote_ip_address -p
I get the following error: ERROR 2003 (HY000): Can't connect to MySQL server on 'REMOTE_IP_ADDRESS' (10061)
Firewall is turned off completely on the Mac Mini
There is nothing in the my.cnf file
OS is Sierra
That's all I can think of at the moment but any advice would be greatly appreciated and any more information required can be provided.
PS. evidently I'm not very good with MAC machines/networks
For anyone that reads this I had a very specific issue. I installed MySQL using homebrew. Homebrew binds MySQL to 127.0.0.1 therefore will only allow connections to MySQL from the same machine no matter what you try to do. To fix it I've had to edit /usr/local/Cellar/mysql//homebrew.mxcl.mysql.plist and replace --bind-address=127.0.0.1 with bind-address=*.
MySQL has an internal firewall of users/IPs. Even if you can connect locally, you might not have permission remotely:
Try this as root user on the MySQL server (locally first!)
GRANT ALL ON <db>.* TO '<user>'#'<remoteIP>' IDENTIFIED BY '<password>';
Where
<db> is the name of the DB
<user> is name under which you connect
<remoteIP> is your external office IP FROM which you are trying to connect
<password> should be self-explanatory!
This will explain the options better
I am using a synology 713+ nas server, and just started using MySQL with it.
I created a database, a table and a user with '%' as host, so it should be able to connect from anywhere.
Using the local ip to the nas-server, I am able to connect to the database without a problem. But when I try using the external ip, I get the following message instantly;
'Unable to connect to any of the specified MySQL hosts.'
In the 'my.cnf' file, I have disabled 'skip-networking' and set 'bind-address' to 0.0.0.0.
I am unable to see the 'bind-address' variable in phpMyAdmin, so I am unsure if it is actually using it.
If I try to connect while the database is offline, I times out after 30 seconds, but when it is online it refuses instantly, which tells me that it is able to find the server, but not allowed to connect.
What in the world is going on, and what can I do?
Edit:
All ports on the nas are open, and my router is forwarding port 3306 to the nas.
Restarting mysql and the whole nas did not work.
I suspect the 'bind-address' variable is not being used...
I had a similar problem and I solved it this way:
Try to create a new user from sql command of phpmyadmin like this:
CREATE USER 'myuser'#'%' IDENTIFIED BY 'mypassword'; GRANT ALL ON *.* to myuser;
and use this user for the connection.
MariaDB 10 default port is 3307
how do I find out what my database hostname and user login is? I've tried localhost and root#localhost but no success.
Failed to connect to database host.domain.com:3306 user:root. Please
check the database settings you provided and verify that MySQL is up
and running.
Assuming that mysql is running and you have credentials that work, you can get all the host and user information from the mysql database once you are running mysql successfully - "select User,Host from mysql.user" for example.
But, it looks like your problem is that you can't log into mysql.
If you don't have a valid credentials to your own database, one has to wonder how you managed to lose them. That happens, however, and the way to reset those credentials is described in detail at http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html.