How can I get a list of all the MySQL databases that exist on a server using PHP?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 8 years ago.
回答1:
$result = mysqli_query($db_conn,"SHOW DATABASES");
while ($row = mysqli_fetch_array($result)) {
echo $row[0]."<br>";
}
回答2:
$dbcnx = mysql_connect ($dbhost, $dbusername, $dbpassword);
$result = @mysql_query('SHOW DATABASES');
while ($row = mysql_fetch_array($result)) {
print_r ($row)
}
回答3:
At the MySQL prompt, SHOW DATABASES
does what you want.
You can run this command as a query from PDO or the native PHP MySQL library and read the returned rows. Pretend it is a normal select.
You will only see the databases that the account used to connected to MySQL can see.
回答4:
The MySQL command for this is
SHOW DATABASES
See the manual for more info on the SHOW command
回答5:
Just use SHOW DATABASES
.It will show all the databases present in your MySQL.
回答6:
Write the SQL query:
show databases