找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
mysql
在线安装在Xshell中(yum installmysql)(mysql-server客户端)
rmp -qa|grep -i mysql--查看是否安装成功
1.启动service mysql start
2.mysqladmin -uroot password"123456"设置密码
3.登录mysql -uroot -p123456
4.service mysqld status 查看是否启动(is runing...代表启动)
5.service mysqld stop 关闭或者ctrl+c
6.service mysqld restart重启
7.set password for username @localhost = password(newpwd);(重置密码为newpwd)
8.show databases;--显示所有数据库名字
show--查看显示数据库或者表
use--进入数据库
desc--进入表
9.create database dcs3;创建一个名字为dcs3的数据库
10.drop database dcs3;删除一个数据库dcs3
11.database changed数据库已更改的意思代表进入成功
12.show dcs3 tables 查看dcs3有哪些表
13.creat table student创建一个名字叫做student的表
14.desc student;查看表结构
field--字段(id.name.等)
type--数据类型(into(20))
Null--是否为空(no  or  yes)
primarykey--主键(pri唯一)
default--默认值
extra--备注
15.alter table test rename test1;--修改test表名为test1
16.alter table test change id sid into(20);把test表中的id改为sid并且删除了备注里的自增长(auto_increment)
17.alter table test add sex int(20) after id给test表添加一个sex字段,放在id后面
18.alter table test add(sex1 int(20),age2 int(20));同时添加两个字段默认放置在最后面。
19.alter table test drop sex;删除test表中的sex字段
20.alter table test drop sex1,drop sex2;同时删除两个字段
21.creat table test1(id int(20))primary key auto_increment;创建一个test1表并且设置一个id字段
22.alter table test change id id int(20);删除test表中的id的自增长,且不改变字段名
23.alter table test change id id int(20)auto_increment给test表的id加上自擅长约束
24.alter table test modify class int(20) after id;在test表中把class字段移到id后面
25.删除主键报错,需要先删除自增长
26.alter table test change id id int(20) primary key auto_increment;同时添加主键和自增长
27.select * from test;查看表中的数据(类比和desc的不同)

分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册