How can I get a list of MySQL databases in PHP using PDO?

前端 未结 4 594
既然无缘
既然无缘 2020-12-16 16:13

I wonder how can I get the list of MySQL databases in PHP using PDO without having to connect to a database first ( I mean no dbname in dsn )?

Usually I used to use

4条回答
  •  失恋的感觉
    2020-12-16 16:28

    You can use

    show databases
    

    or a query on the information_schema:

    select schema_name from information_schema.schemata
    

提交回复
热议问题