Mysql 常用命令

来源:互联网 发布:如何评价慈禧 知乎 编辑:程序博客网 时间:2024/06/08 09:45

 

Mysql 常用命令

启动服务

1.       windows 服务方式

2.       通过命令行
net start mysql
à启动数据库(其中mysqlservice name)
net stop mysql
à关闭数据库

3.       连接数据库
à命令行输入:mysql –u用户名 –p密码   出现welcome信息,表示成功

4.       使用show语句找出在服务器上当前存在什么数据库
à show databases; (注意要有分号结尾)

5.       删除数据库
àdrop database dbname;
àcommit;

6.       创建数据库
àcreate database dbname;

7.       选择要使用的数据库
àuse dbname;

8.       查看现在的数据库中存在哪些表
àshow tables;

9.       创建一个数据表
àcreate table person(

Id varchar(32) not null primary key,
name varchar(20) not null,

Password varchar(20) not null

)

10.   显示表达结构
àdescribe tablename;

11.   向表中加入记录:
àinsert into tablename value(…);

12.   导入.sql文件命令(例如:c:/person.sql)
à
user rex;
àsource c:/person.sql

13.   删除表
àdrop tablename;

14.   删除表中的全部记录
àdelete from tablename;

15.   更新
à

16.   查看服务器的版本号和当前日期
àselect version(),current_date;
àselect version();select now();

17.   使用mysql用作一个简单的计算器
àselect pi();
àselect sin(pi()/4),(4+1);

18.   查看用户:
àselect user();

19.   使用load命令:
à
load data local infile ‘c:/rex.txt’ into table person;
     

 

原创粉丝点击