功能:利用mysql和mysqli两种连接数据库的方法,取得Mysql服务器上的所有数据库和库中的所有表。
环境:自己用分开安装apache mysql php搭建的环境
操作系统是:windows 10
代码如下:
结果如下:
0=>information_schema
CHARACTER_SETS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
ENGINES
EVENTS
FILES
GLOBAL_STATUS
GLOBAL_VARIABLES
KEY_COLUMN_USAGE
PARAMETERS
PARTITIONS
PLUGINS
PROCESSLIST
PROFILING
REFERENTIAL_CONSTRAINTS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
SESSION_STATUS
SESSION_VARIABLES
STATISTICS
TABLES
TABLESPACES
TABLE_CONSTRAINTS
TABLE_PRIVILEGES
TRIGGERS
USER_PRIVILEGES
VIEWS
INNODB_BUFFER_PAGE
INNODB_TRX
INNODB_BUFFER_POOL_STATS
INNODB_LOCK_WAITS
INNODB_CMPMEM
INNODB_CMP
INNODB_LOCKS
INNODB_CMPMEM_RESET
INNODB_CMP_RESET
INNODB_BUFFER_PAGE_LRU
1=>access_control
collection
collection2permission
permission
signup
user
user2collection
2=>db_bcty365
tb_bb
tb_bbqb
tb_bbs
tb_bccd
tb_bccdjj
tb_city
tb_cjwt
tb_dd
tb_leaveword
tb_reply
tb_sjxz
tb_soft
tb_tell
tb_type
tb_type_big
tb_type_small
tb_user
tb_xlh
3=>db_nethard
tb_member
tb_upfile
tb_uptype
4=>db_reglog
5=>mysql
columns_priv
db
event
func
general_log
help_category
help_keyword
help_relation
help_topic
host
ndb_binlog_index
plugin
proc
procs_priv
proxies_priv
servers
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
6=>performance_schema
cond_instances
events_waits_current
events_waits_history
events_waits_history_long
events_waits_summary_by_instance
events_waits_summary_by_thread_by_event_name
events_waits_summary_global_by_event_name
file_instances
file_summary_by_event_name
file_summary_by_instance
mutex_instances
performance_timers
rwlock_instances
setup_consumers
setup_instruments
setup_timers
threads
7=>php_study
8=>phpbook
addressbook
9=>regi
member
10=>test
11=>world
city
country
countrylanguage
Array ( [0] => information_schema [1] => access_control [2] => db_bcty365 [3] => db_nethard [4] => db_reglog [5] => mysql [6] => performance_schema [7] => php_study [8] => phpbook [9] => regi [10] => test [11] => world )
本文转自孤舟夜航之家博客51CTO博客,原文链接http://blog.51cto.com/cysky/1693826如需转载请自行联系原作者
cysky