简明教程 - 使用MySQL
出处:www.mysqlpub.com ,不断完善更新中。http://www.mysqlpub.com/thread-59102-1-1.html , 转载请注明。进入MySQL#mysql -h192.168.110.xxx -uroot -p -P 3306 (回车后输入密码,即可进入mysql)
1、显示数据库列表mysql>show databases;(注:MySQL语句分隔符为“;”)默认有三个数据库:information_schema、mysql和test。information_schema库为MySQL默认字典库,mysql库很重要它里面有MySQL的系统信息,我们改密码和新增用户,实际上就是用这个库进行操作。
2、显示库中的数据表:mysql>use mysql;(指定mysql库)mysql>show tables;
3、显示数据表的结构:mysql>describe yourtablename; / mysql>desc yourtablename
4、建库:mysql>create database yourdbname;
5、建表:mysql>create table yourtablename (columnname colunmtype, ...);
6、删库和删表:mysql>drop database yourdbname;mysql>drop table yourtablename;
7、将表中记录清空:mysql>delete from yourtablename;
8、显示表中的记录:mysql>select * from yourtablename;
9、举个例子:一个建库和建表以及插入数据的实例mysql>create database world; //建立库worldmysql>use world;//打开库worldmysql>create table city //建立表city (IDint(3) not null auto_increment , Name char(30) notnull default '', CountryCode char(3) not null default '', District char(20) not null default '', Population integer not null default '0', Primary key ('ID') ); //建表结束//以下为插入字段mysql>insert intocity values('','Kabul','AFG','Kabol','1780000');mysql>insert intocity values('','Beijing','CHN','Beijing','1780001');
更多信息:MYSQL初学者使用指南
对于初学者,用command line client方式操作数据库好?还是用workbench可视化工具操作好?
页:
[1]