Specify Database Name for MySql Database

Posts   
 
    
techpro
User
Posts: 8
Joined: 08-Dec-2021
# Posted on: 10-Mar-2022 21:36:02   

I'm trying to start a new project and connect to a MySql database. I enter in the server IP, user name and password, but there is no where to enter the database name I want to connect to. It keeps failing trying to connect to the database named "mysql", but I don't have a database named mysql... How can I get this connected?

How can I enter in the database name I'm trying to connect to?

Exception message:
-------------------------------
Exception type: MySqlException
Access denied for user 'username'@'xxx.xx.xx.xxx' to database 'mysql'

Using 5.9 (5.9.0) RTM

Walaa avatar
Walaa
Support Team
Posts: 14982
Joined: 21-Aug-2005
# Posted on: 11-Mar-2022 00:32:51   

First step is to log-in to the database server. If successful, then you would get a list of databases on that server to pick from which.

techpro
User
Posts: 8
Joined: 08-Dec-2021
# Posted on: 11-Mar-2022 16:25:16   

If that were true it wouldn't be failing my connection saying it can't access the database "mysql". I can connect to the database using MySqlWorkbench from the same machine using the same IP, Username and Password as well as from another Visual Studio project. I just can't login with LLBLGen...

techpro
User
Posts: 8
Joined: 08-Dec-2021
# Posted on: 11-Mar-2022 16:47:45   

I guess I need root level privileges looking at some other threads. But my user has root level privileges to this database... So I don't know what is wrong.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 12-Mar-2022 09:47:34   

We use the 'databases' schema of the DevArt's ado.net provider to obtain all databases on a MySQL server. (MySqlConnection.GetSchema("databases") )

As that's DevArt's schema query we don't know the exact SQL but I can assume it'll try to obtain the metadata from MySQL's own metadata tables. You can reproduce this by doing something like:

using(var con = new MySqlConnection("... connection string"))
{
    con.Open();
    var schema = con.GetSchema("databases");        // this likely gives the same error
}

So if you want to connect and obtain the metadata of database Foo on the server, it still needs to be able to obtain meta data of the server itself, namely which databases there are.

Frans Bouma | Lead developer LLBLGen Pro
techpro
User
Posts: 8
Joined: 08-Dec-2021
# Posted on: 14-Mar-2022 17:00:28   

I'm surprised it doesn't let you specify a specific database and not query for all databases. Seems like that is a permission not every admin would want a user to have. There could be other clients that have databases on that server, and you wouldn't want one client to see other client's database names.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 15-Mar-2022 09:26:57   

For production systems, sure. But LLBLGen Pro is a development tool, so the philosophy is that the developer works with a development server, where the schema is accessible for the people who have to do development. Again, we simply obtain the list of databases to connect to using the MySqlConnection.GetSchema("databases") call, as we support multiple databases per project (so we have to let the user choose).

Frans Bouma | Lead developer LLBLGen Pro