MySql常用命令
来源:互联网 发布:g3营销软件 编辑:程序博客网 时间:2024/06/14 02:09
- 登陆,如果没有在环境变量中配置路径,则需要定位到mysql安装的bin目录,输入mysql -uroot -p,回车,输入密码,回车。
- 修改密码:
- set password for root@localhost = password(‘root’);
- mysqladmin -uroot -p123456 password 123;
- select version(); 查看mysql版本。
- status;查看mysql详细信息。
- show databases 显示所有数据库。
- show variables like ‘%datadir%’ 显示数据库存放路径。
- create database dataname 创建名为dataname的数据库
- drop database dataname 删除名为dataname的数据库
- drop database if exists dataname 删除一个不一定存在的数据库
- use smart 连接(使用)名为smart的数据库
- create table tablename (<字段名1><类型1> [,…<字段名n><类型n>]); 创建数据表,例:
> create table myclass(> id int(4) not null primary key auto_increment,> name char(20) not null,> sex int(4) not null default '0',> degree double(16,2));
- show tables; 显示数据表。
- describe tableName;显示表结构。
- drop table tablename; 删除数据表
- insert into user(userName, password, email) values(‘zhibo405’, ‘zhibo405’, ‘444894216@qq.com’);插入时可以不写自增的主键。
- 查找:
- select * from tablename;查询所有信息
- select sex from myclass where name=’Tom’;
- 删除:
- delete from myclass where name=’Tom’;
- delete from table; 清空表
- 更改:
- update myclass set sex=1 where name=’Tom’;
- update mycalss set sex=1,age=2 where name=”Tom”;
- alter table t1 rename t2; 修改表名
- alter table t2 add c varchar(30);增加列
- alter table t2 modify a tinyint not null, change b c char(20);修改列
- alter table t2 drop column c; 删除列
0 0
- MySQL常用命令
- MySql常用命令
- MySQL常用命令
- mysql常用命令
- mysql常用命令
- mysql常用命令
- Mysql常用命令
- MySQL常用命令
- mysql 常用命令
- MySQL常用命令
- mysql常用命令
- MySql常用命令
- MySQL常用命令
- mysql 常用命令
- mysql常用命令
- mysql常用命令
- mysql 常用命令
- MySQL常用命令
- 搜索专题(BFS&&DFS)HDU1175-连连看
- PreferenceActivity的使用
- LeetCode 58. Length of Last Word
- JavaScript中的匿名函数及函数的闭包
- 题目<2016/11/30>
- MySql常用命令
- Linux磁盘管理基础
- 【topcoder】570div1 900 CurvyonRails【费用流】
- 月末随笔
- Activity启动的四种模式
- ScrollView嵌套listview出现的问题
- javascript数据类型
- 坚持#第111天~rexhang都优秀成传说了,分分钟搞定一个项目,这有什么好苦逼的,我也要变优秀!
- 【数据结构】二叉树部分面试题解法