PHP获取MySQL所有数据库

需要root账户权限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$conn = mysqli_connect("localhost", "root", "123456") or die("数据库服务器连接失败");
$ret = mysqli_query($conn, "SHOW DATABASES");

//遍历方式一
while ($row = mysqli_fetch_object($ret))
{
echo $row->Database . "<br>";
}

//遍历方式二
while ($row = mysqli_fetch_assoc($ret))
{
echo $row['Database'] . "<br>";
}

mysqli_close($conn);

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :