Configuring Umbraco with MySQL: "Could not connect to database" - c#

I am trying to install Umbraco for the first time, and I am using this tutorial. I want to use MySQL instead of MS SQL (which is not shown in the tutorial).
When using the installation wizard, this is the result:
The error logged in UmbracoTraceLog.txt is:
Configured database is reporting as not being available!. Exception: MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException (0x80004005): The requested name is valid, but no data of the requested type was found
MySQL is up and running, and I ended up trying the root user just in case it was a permissions issue. I wounder if the table umbraco-cms should already be filled (what would then be the point of the wizard? and where do I find that info?).
I have searched quite a lot about how to install Umbraco using MySQL but I haven't found the necessary info. Other posts indicate that it shouldn't be that difficult.

Related

Access denied when connecting to an AWS MySql database from an ASP.NET application

I've just set up a MySQL database in AWS, however every time I try to connect programmatically I get an access denied exception. Connecting through MySQL Workbench works absolutely fine.
I've added my IP address to the Inbound Rules in AWS (without it, Workbench can't connect so it's definitely set up somewhat correctly) and even added a rule to allow all IP addresses for all traffic:
This is a bare minimum example of what I'm trying to do:
using MySql.Data.MySqlClient;
MySqlConnection connection = new(CONNECTION_STRING);
connection.Open();
which throws the exception on connection.Open().
Connection string:
Server=aa11sgbkk911b5j.cevakqici96g.eu-west-2.rds.amazonaws.com;Database=ebdb;Uid=username;Pwd=password;
The exact exception:
MySql.Data.MySqlClient.MySqlException
HResult=0x80004005
Message=Authentication to host 'aa11sgbkk911b5j.cevakqici96g.eu-west-2.rds.amazonaws.com' for user 'username' using method 'mysql_native_password' failed with message: Access denied for user 'burntorangeadmin'#'cpc150000-brnt4-2-0-cust812.5-2.cable.virginm.net' (using password: YES)
Source=MySql.Data
...
Does anyone have any idea why I can't connect?
I originally had the database coupled to an Elastic Beanstalk instance, and after creating a new one separately everything worked as expected.
So still no actual solution to why it wasn't working in the first place, but decoupling has done the trick.
Check that you have granted the appropriate privileges to the user account
Eg.
CREATE USER 'cdcuser'#'%' IDENTIFIED WITH mysql_native_password BY "cdcpwd";
GRANT ALL PRIVILEGES ON *.* TO 'cdcuser'#'%' ;
FLUSH PRIVILEGES;

Fatal NServiceBus exception when starting endpoint, cannot open database

We just made some changes to our project and deployed it. We have 7 endpoint databases in our SQL Server database for NServiceBus. We recently added 2 more. One of the two services using one of the two new endpoints fails to start. When looking at our log file we see the following error:
FATAL NServiceBus.GenericHost [(null)] - Exception when starting endpoint.
System.Data.SqlClient.SqlException (0x80131904): Cannot open database "A_NSBEP_WebEventProcessor" requested by the login. The login failed. Login failed for user 'xxxx'
The connection string is
'connection.connection_string'='Data Source=localhost\DevSQLServer;Initial Catalog=A_NSBEP_WebEventProcessor;Integrated Security=true;Enlist=true'
All of the connection strings are configured in OctopusDeploy. They are all identical except obviously for the database name. All of the other services start and login to their respective endpoint with no problem. I even went through the process of creating a .udl file, connecting to the database and using that slightly different connection string. Still without success.
Any thoughts?

can't add a sql database to my project

I have VS 2013 ultimate. I'm trying to add a sql database file to my project App_Data. What I did was I right-clicked App_Data, added new item, named my file database1.mdf, and then tried to add the file, but when i do it gives me this error
A network-related or instance-specific error occurred while establishing a connection to sql server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL server is configured to allow remote connections. (provider: SQL Network interfaces, error: 50 - local Database runtime error occurred: Cannot create an automatic instance. See the windows application event log).
Now the werid part is. This USE to work. Til last night when I deleted something something or messed with something, I really can't remember what. I also noticed my master.mdf file is gone.
I went into control panel and services to see if an instance of sql server is running. It is not, but it is set to automatic. I tried to run it through services, and got this error.
"Windows could not start the SQL server (SQLEXPRESS) on local computer. For more information, review the system event log. If this is a non-microsoft service, contact the service vendor, and refer to service-specific error code 17113"
This is driving me crazy, I'm about to format my windows, and reinstall everything. I spent a day trying to figure out what i might have messed with or deleted that screwed this up, because it was working correctly the other day. Please help.
Open up the Command window(run->cmd or "Win"+"R") and type:
C:\Users\xxx\sqllocaldb delete "v11.0"
The following row should be shown:
LocalDB instance "v11.0" deleted
Then type the following row:
C:\Users\xxx\sqllocaldb create "v11.0"
The following row should be shown:
LocalDB instance "v11.0" created with version 11.0

Visual C# 2010: Unable to connect to XAMPP localhost

I am unable to connect to XAMPP localhost in my C# Windows form application.
My code is:
SqlConnection connection = null;
try
{
connection = new SqlConnection("user id=root;" +
"password=12345678;" + "server=localhost");
connection.Open();
}
catch (Exception exptn)
{
MessageBox.Show(exptn.ToString());
}
I made sure to include "using System.Data.SqlClient;" so that my code runs. The timeout error I get at runtime is:
"System.Data.SqlClient.SqlException (0x80131904): A network-related or
instance-specific error occurred while establishing a connection to
SQL server. The server was not found or was not accessible. Verify
that the instance name is correct and that SQL server is configured to
allow remote connections."
There was more to the error message, but it was uncopyable and too long to post here. I have tried to install MySql and the .NET MySql connector separately from XAMPP. I added MySql.Data as a reference in Solution Explorer (My research told me to add MySql.Data and MySql.Web, and MySql.Data was the only one listed in the options.). Another source told me to add a Microsoft ODBC Data Source in Server/Database explorer, but the option was not available in Database Explorer. I have made sure XAMPP is running and working properly in phpMyAdmin, and I am able to create tables and run queries there. Many sources also seem to have different opinions as to what is needed in the connection string.
I am completely at a loss as to how I am supposed to connect to localhost databases from another application on the same computer. Forgive me if I am overlooking something basic or if this is a noob question, but I know little about connecting to databases (this type of thing is precisely the reason why). Can anyone help me connect to XAMPP localhost from C#?
Install MySQL Connector from Oracle and then use class MySqlConnection.
Here is the download link -
http://www.mysql.com/products/connector/
Download the driver for ADO.Net and the documentation to use it is here -
http://dev.mysql.com/doc/connector-net/en/connector-net-introduction.html
SqlConnection is for MQ SQL server only and thus it is looking for a instance of MS SQL Server to connect to and it fails to connect since none exists. This explains the error message.

"Can not find server or is not available" on test server but not while debugging

I keep getting an error when trying to access the database from a web site it returns an error that it can't find the server or it's inaccessible.
Now I did a search and I found many possible reasons - I turned on named pipes and also did what this link suggested (i.e. set the IP addresses to "enabled") yet I'm still getting the error.
Error SqlException: System.Data.SqlClient.SqlException (0x80131904):
Error An error has occurred with the network or the occurrence when
connecting to SQL Server. Can not find server or is not available.
Verify that the instance name is correct and that the configuration of
SQL Server allow remote connections. (provider: Named Pipes Provider,
error: 40 - Could not open a connection to SQL Server) at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) at
I also downloaded this little app and I copy/pasted the connection string from the web.config used in IIS for this site and the app is able to connect and query the same database being targeted by the web site.
And, as the title says, this error is utterly missing when I debug it in VS2010. What could be causing this error when launching from the server?
Edit: the connection string includes a user name and password (it's not Windows Authentication).
Most likely a security issue. If using windows authentication then make sure the thread pool that the web application is running as has sufficient DB access\privileges.
The issue is that the web.config references another config file
<appSettings file="config/dev.config">
and so the connection string in web.config is ignored over the one in dev.config - an error to have it in both (the one on the test server was created by someone else and worked on static pages - it only failed when the website had to query the database), that's why the version in Visual Studio was running fine.

Categories