Get list of MySQL databases, and server version?

前端 未结 3 1297
夕颜
夕颜 2021-01-15 16:58

My connection string for MySQL is:

\"Server=localhost;User ID=root;Password=123;pooling=yes;charset=utf8;DataBase=.;\"

My questions are :

3条回答
  •  时光取名叫无心
    2021-01-15 17:18

    To get the list of databases, you can use SHOW DATABASES:

    SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | test               |
    +--------------------+
    3 rows in set (0.01 sec)
    

    To get the version number of your MySQL Server, you can use SELECT VERSION():

    SELECT VERSION();
    +-----------+
    | VERSION() |
    +-----------+
    | 5.1.45    |
    +-----------+
    1 row in set (0.01 sec)
    

    As for the question about the connection string, you'd want to put a database name instead of the dot, such as Database=test.

提交回复
热议问题