C # Read name of local or remote Database

0

I need you to help me with something I do not know where to start.

The idea is to read with C # the name of the database (MySQL) that is running on the pc where it is running, and subsequently, the tables that are under it.

The latter is easy:

cmd.CommandText = "SHOW FULL TABLES FROM data_base";

But, with what code can I get the name of the database ?, that is, if I have a database with the names: data_base , data_base1 , data_base2 , etc ... get them.

A thousand thanks in advance.

    
asked by Jacobo Rodriguez 18.06.2018 в 23:44
source

1 answer

2

to see all the databases (where you have some kind of privilege)

"SHOW DATABASES;"

to know the current database

"SELECT DATABASE();"
    
answered by 19.06.2018 / 00:12
source