如何使用mysql_MySQL快速入门基础教程 怎么使用MySQL

进入 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');

出处:mysqlpub.com ,不断完善更新中。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值