root@c67b08791485:/# mysql -h localhost -P 3306 -u root -p1234 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.6-m16 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3.2 Navicat
其他工具,请自行Google
4. 简单SQL语句
4.1 显示所有数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | eladmin | | example | | lfstudio | | mysql | | performance_schema | | shiro | | shiro2 | +--------------------+ 18 rows in set (0.01 sec)
我这里有一些自己测试的数据库
4.2 切换到指定数据库
1 2 3 4 5
mysql> use shiro2; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Databasechanged
4.3 显示当前数据库中所有表
1 2 3 4 5 6 7 8 9
mysql> show tables; +-----------------------+ | Tables_in_shiro2 | +-----------------------+ | base_admin_permission | | base_admin_role | | base_admin_user | +-----------------------+ 3 rows in set (0.00 sec)
4.4 显示指定表中所有列
1 2 3 4 5 6 7 8 9 10 11 12 13
mysql> show columns from base_admin_role; +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | role_name | varchar(30) | NO | | NULL | | | role_desc | varchar(100) | YES | | NULL | | | permissions | varchar(20) | YES | | NULL | | | create_time | varchar(64) | YES | | NULL | | | update_time | varchar(64) | YES | | NULL | | | role_status | int(1) | NO | | 1 | | +-------------+--------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec)