1 mysql本地连接数据库
>mysql -h localhost -u root -proot 注意-p后面没有空格,是直接跟上密码
或者
>mysql -h localhost -u root -p
Enter password 提示数据密码
2 mysql远程连接数据库
注意: mysql数据库要允许远程连接,否则是连接不上的
2.1 通过navicat工具连
2.2 命令行远程连接
>mysql -h ip -P 3306 -u root -proot
3 mysql的内置数据库
当安装上mysql时,就自动创建了几个数据库
information_schema库中存放了服务器所维护的所有其他数据库的信息,如数据库名,数据库的表,表栏位,以及权限等,也就是这个库中放了整个数据库的一些基本的信息。
其中有几个重要的表
1) information_schema.SCHEMATA 存放了所有的数据库名
select SCHEMA_NAME from information_schema.SCHEMATA 查看所有的数据库
2) information_schema.TABLES 存放了所有数据库的表名
select table_name from information_schema.TABLES where information_schema.TABLES.table_schema='xxx' 查看某个数据的所有表
select table_name from information_schema.TABLES where information_schema.table_schema='xxx' limit [N],1; 一个个的表的看
information_schema.CLOUMNS 存放了所有数据库的列名
select cloumn_name from information_schema.Columns where table_schema='xxx' and table_name='yyy' 查看xxx库yyy表的所有列
select cloumn_name from information_schema.Columns where table_schema='xxx' and table_name='yyy' limit [N],1; 一列列的看