How to remotely connect to ClearDB in an Azure Website? - mysql

I have created a free Azure Website with Wordpress on it. A ClearDB mysql database was automatically created.
I want to remote connect to the DB using something like MySQL Workbench.
I used the credentials from the "View connection strings" in the azure portal dashboard, but there is an error connecting.
I read in some post that the db itself is hosted in azure cloud and thus can not be accessed.
Have anyone managed to administrate a DB like this ?

Mostly hoster don't allow an external connection with shared hostings.
When you use an outside client, your server has to be configured to allow this external connection.
Firewall rules :
You must to set password before make this, for security improvement.
You must to update firewall and make rules to open the mysql port (3306) on the server that is running the mysql database.
Set user IP :
Add an user account or replace ip address.
Adding users :
CREATE USER 'monty'#'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'monty'#'localhost'
Replace ip address (be careful don't use this on the root user) :
RENAME USER 'user'#'ipaddress2' TO 'user'#'ipaddress2';
To allow all ip replace ip adress by %.
See more :
Security Guidelines.
How to determine if a port is open on a Windows server? or www.portcheckers.com.

Yes, it is possible to administer your ClearDB MySQL database in MySQL Workbench. I have several Azure Wordpress sites that I connect to just as you describe -- create the Azure site, view Connection Strings, type those credentials into MySQL Workbench, and voila. #Yaron, Can you be more specific about what you've tried and maybe we can troubleshoot from there?

Related

how to connect to azure database for mysql, from azure app service with wordpress docker image?

I have an azure app service, using the latest wordpress image from docker hub. The screenshot for the azure app service:
Then in the azure app service -> application setting, I added the following key/value pairs which will be used to connect Azure database for mysql:
WORDPRESS_DB_HOST
WORDPRESS_DB_NAME
WORDPRESS_DB_PASSSWORD
WORDPRESS_DB_USER
screenshot:
Inside my Azure database for mysql, I have enabled public access / allow public access from any azure service / also add my client ip and this ip range 0.0.0.0 - 255.255.255.255. I can access it from my client and create the database which will be used by azure app service. Screenshot like below:
in server parameters, I also turn off the require_secure_transport setting:
At last, I tried to launch the site, but it throws the error "Error establishing a database connection", screenshot below:
I'm new to wordpress / docker, and don't know how to fix this issue. I also reviewed some videos / docs, and didn't see any other configuration differences. Could you please guide me how to fix this issue? Thanks very much.
You received this error message.
Warning: mysqli_real_connect(): (HY000/1045)>: Access denied for user 'ivan'#'52.xx.xxx.xx' (using password: YES)
It means MySQL received, processed, and rejected your WordPress instance's attempt to connect. So you know the hostname is right and your cloud provider's firewall settings allow your WordPress instance to exchange network data with your MySQL instance.
What's wrong?
MySQL's user name / account name setup has a quirk. An account name can look like 'ivan'#'localhost' or 'ivan'#'%' (or even something like 'ivan'#'192.0.22.33').
The first of those only allows login from localhost (or via tunneling via ssh). The second allows login from '%', meaning any host. You need the second one for your WordPress instance to get access to MySQL.
When you're logged in to MySQL from your machine, do this.
SELECT host, user FROM mysql.user WHERE user='ivan';
You should see two rows, like these
host user
---- ---
% ivan
localhost ivan
It's possible the account with '%' as the host is missing. If so that means you need to create another MySQL account and give it access to your database. Do that like this.
CREATE USER 'ivan'#'%' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
Next, make sure the user account you just created -- the one your WordPress software will use to connect to MySQL -- has access to your database.
GRANT ALL PRIVILEGES ON wordpress.* TO 'ivan'#'%';
FLUSH PRIVILEGES;
If you still get the error message, it's possible the password on your 'ivan'#'%' account doesn't match what you put into your WordPress configuration. You can change it with
ALTER USER 'ivan'#'%' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
If it still gives the same error message, it's possible that your cloud vendor requires TLS to connect to MySQL. You may want to consult their support team about that.
(This is a common stumbling block setting up new WordPress instances.)
ok just to keep and make things clear. all IPs can connect to the DB but are you actually authorized to read/write date in the DB?
I.E. this might be a permission/privilege issue.
I suggest double checking user privileges and determine who can do what on your DB
Best Regards. :-)

Can't Connect to MySQL instance Remotely that is running on EC2 Instance (Not RDS)

I have seen a lot of posts that claim they are running an RDS instance of MySql in which they cannot connect to, but I am not running RDS.
I used my EC2 insance to host my wordpress blog which was installed using the Web Platform Installer.
This setup the wordpress schema and data that I needed and I have been running it for a couple years.
I want to be able to access this database remotely instead of only logging into my server.
I have checked and have the following users
root
wpadmin
I have also verified that the port specified in the mysql config is the standard 3306 and I have setup an Inbound Firewall rule to allow 3306 through.
When I try to connect from MySql Workbench, I get the following error message:
Number 3 Is particularly one that I do not know how to check, but I do know that MySql is running and that it is running on 3306. Additionally, I know I am using the correct password.
When I try to connect, the prompt looks like this. Do I need to do something to grant Mysql user permissions or anything?
Based on your GRANT information, you have at least the problem of root user only having access privileges from localhost. You would need to create a root#% user (or a more specific host/IP instead of % if you have a reliable address). That would allow external access so long as your EC2 security group also allow access on port 3306 (either globally or to a more restrictive IP address or IP range).
Of course the security implication here is that you are opening up access to MySQL that you might not want to make more accessbile to potential attackers. For this reason, I would recommend you access your DB via SSH tunnel, which is supported by MySQL workbench. This will in essence allow you to shell into the host your your access key and then access as root#localhost.

How do I allow mysql client connections to be established with our mysql web server?

It seems that the web server is preventing me to change permissions to the user. It does not allow me to GRANT ALL ON foo.* TO bar#'202.54.10.20' IDENTIFIED BY 'PASSWORD'; and returns an error message of access denied for the username that I'm using.
It also appears that the folder etc in the file manager is empty whereas in the given link below, it shows that the bind address can be edited in the my.cnf inside etc folder.
How do I allow my mysql database to be accessible remotely by any computer?
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
The bind option in my.cnf is not that problem (since you can connect, the MySQL server is just not letting you in), and judging from the screenshot, you don't seem to have the permissions to edit that file anyways.
Most likely, your request is not coming from 202.54.10.20, or you have mistyped username/password. If the web application runs on the same machine as the MySQL server, connections will come from somewhere in the 127.0.0.0/8 range.
Look at the connection string in your web application:
If it is a public IP address, check username/password and originating IP.
If it starts with 127., GRANT to your local address.
If it is localhost, you're connecting via Unix socket instead of TCP. This is a good thing, and you can simply GRANT to localhost.
To issue this command:
GRANT ALL ON foo.* TO bar#'202.54.10.20' IDENTIFIED BY 'PASSWORD';
You MUST connect to the database first. So if you don't have permissions to remotely access database, you should go to the database server host and login locally, using root#localhost.
I just found out that there is an option which basically do the same thing as what I wanted it to be doing. There is an option for the user to enable remote database access to its clients.

Remote database access (From Parallels power panel)

So i have this server (hosting service) known as Parallels power.
Now on this hosting service my database is configured and stored.
Now the database is MySQL and if i go to its administration panel i get the following details:
Server version: 5.5.33
Protocol version: 10
Server: Localhost via UNIX socket
User: root#localhost
Now i want to connect to this database to this database remotely however i am not sure how?
In my paralle control pannel i get a container name for the host server Container ****.unoeuro-server.com However this wasnt the host i can connect to my database at.
So i decided to send them an email to check if i was blocked out and they replied:
****.unoeuro-server.com is not your Host and your firewall is not blocking outside calls.
So my question to you guys how the hell can i connect to the database remotely :S?
If you have privilege in phpMyAdmin to manage users (root privilege), you can create a user with global access to it. so you can access to your panel from desired remote Host.
UPDATE: It seems you have root privilege to manage users in phpMyAdmin, so when you logged in to your phpMyAdmin panel go to User tab then click add user link then fill your information but in host field select any host or your desired host.

MySQL connection for every host

I'm making a winforms app in vb.net that connects to a mysql database on my webserver to read and write data, this all works fine.
But i have to allow the users ip to remote connect to the database.
Is it possible to give everyone access to the database? The user account will not have all rights an the data isn't very important if it got lost.
The user account and connection details are hard coded.
I know this isnt secure but that doesnt really matter.
Yes, that's very well possible. In your mysql privileges table you'll have to grant a wildcard (%) host access to the user. Then in your VB.NET code simply use the address in the connectionString.
Yes, you can GRANT permissions on the database to the same user with wildcards in the host. More information here.
You can specify wildcards in the host name. For example, user_name#'%.example.com' applies to user_name for any host in the example.com domain, and user_name#'192.168.1.%' applies to user_name for any host in the 192.168.1 class C subnet.
The simple form user_name is a synonym for user_name#'%'.
That way every application connects to the database from random hosts and uses the same username/password in the connection string to authenticate, and MySQL will allow it because the host part of the permissions isn't explicitly specified.
But i have to allow the users ip to remote connect to the database.
Why?
Two other options:
1 - Expose the data as a web service. It's already on the web server...
2 - Build a web app instead of a desktop app.