Mysql 常用命令
来源:互联网 发布:洛瑟玛·塞隆 知乎 编辑:程序博客网 时间:2024/06/04 19:49
1.打开mysql服务 :net start mysql
2.进入mysql工作台 : mysql -h localhost -u root -p
-h表示服务器名,localhost表示本地;-u为数据库用户名,root是mysql默认用户名;
3.显示已有数据库:show databases;
4.新建:
create database 数据库名;
use 数据库名;
create table <表名> ( <字段名1> <类型1> [,..<字段名n> <类型n>]);
mysql> 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));
查看端口:mysql>status;
刷新数据库:flush privileges;
命令:insert into <表名> [( <字段名1>[,..<字段名n > ])] values ( 值1 )[, ( 值n )]
查看所有表:show tables;(use databasename 后)
查看表中字段:show columns from 表名; describe 表名; show create table 表名;查看表中记录 :select * from 表名
显示当前mysql版本和当前日期
select version(),current_date;
6.删除drop database name 直接删除数据库,不提醒
7.插入 mysqladmin drop databasename 删除数据库前,有提示。
命令:insert into <表名> [( <字段名1>[,..<字段名n > ])] values ( 值1 )[, ( 值n )]
insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);
其他:将建表语句提前写在sql.txt中:
mysql > mysql -h myhost -u root -p database < sql.txt
0 0
- MySQL常用命令
- MySql常用命令
- MySQL常用命令
- mysql常用命令
- mysql常用命令
- mysql常用命令
- Mysql常用命令
- MySQL常用命令
- mysql 常用命令
- MySQL常用命令
- mysql常用命令
- MySql常用命令
- MySQL常用命令
- mysql 常用命令
- mysql常用命令
- mysql常用命令
- mysql 常用命令
- MySQL常用命令
- java中equal和==的区别
- 使用NVM安装Node.js
- 手机信息页面1.
- 字符串与整数之间的互换
- js加减乘除丢失精度问题解决方法
- Mysql 常用命令
- 〖随记〗小总结:遇到问题我不怕不怕啦
- 斐讯k2路由多拨
- C++ Primer可能的错误
- css盒模型和定位
- 独木舟上的旅行
- MySQL性能优化
- 使用QuartZ定时发送邮件
- 三洋献瑞