MySQL社区

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 16880|回复: 1

简明教程 - 使用MySQL

[复制链接]
发表于 2015-7-30 18:27:00 | 显示全部楼层 |阅读模式
出处: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; //建立库world
mysql>use world;//打开库world
mysql>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');

更多信息:


发表于 2017-5-5 01:15:07 | 显示全部楼层
对于初学者,用command line client方式操作数据库好?还是用workbench可视化工具操作好?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|申请友链|小黑屋|Archiver|手机版|MySQL社区 ( 京ICP备07012489号   
联系人:周生; 联系电话:13911732319

GMT+8, 2024-3-29 03:11 , Processed in 0.067058 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表