Windows在控制台访问另一台Windows下的mysql以及基本指令

Windows在控制台访问另一台Windows下的mysql:

mysql -u root -h ip地址 -p

eg:

mysql -u root -h 123.123.123.123 -p

mysql基本指令:

1查看mysql状态信——status; 

2显示当前系统端口号——show variables like 'port';

3查看数据库系统所使用的引擎——show variables like '%storage_engine%';

4显示mysql中支持的储存引擎——show engines;

5帮助——help;

6查看系统函数相关帮助——help functions;这时help等价于?

7查看正在使用的数据库——select database();

8查看数据库——show databases;

9查看表——show tables;

10打开我们的某一个数据库——use mysql;

11创建自己的数据库:

create database test01 ;

cteate database if not exists test01;

create database if not exists test01 character set 'utf8';

12查看创建数据库的语法——?create database;

Syntax:你看到的MySQL语法里面的

大括号为:只写一次

中括号为:可写可不写

13删除数据库:

drop database test01;

drop database if exists test01;

14创建表(语法参考——?create table):

create table test01(

id int(30) primary key auto_increment,如果int后面不写,默认11位

name varchar(100) not null;

createdTime datatime not null

birth data not null

)[engine=OnnoDB] [default charset=utf-8];

15显示表结构——desc test01;

16显示表的创建语句——show create table test01;

17向表插入数据(inse):注意null必须写

insert into test01(id,name,createdTime,birth) values (null,'A',now(),now());

insert into test01 values (null,'A',now(),now());

除非——insert into test01(name,createdTime,birth) values ('A',now(),now());

insert into test01 values (null,'A',now(),now()),(null,'B',now(),now();

18 select max(id) from test01;

19update test01 set name='AA' where id=1;

20delete from test01;删除全部数据

delete from test01 where id=1;

21查询分页——select * from test01 limit 3;每页最多显示3条

select * from test01 limit 3,4;4为取得个数,最多取4条,3为从大于3开始取,取4条

select * from test01 order by id desc limit 6,3;

22执行sql文件:

source d:/test01.sqlsource d:/test01.sql

*重要:set names utf8;然后source d:/test01.sqlsource d:/test01.sql

*重要:控制台的编码和数据库的编码不一样解决:set names gbk;

猜你喜欢

转载自blog.csdn.net/qq_23689053/article/details/79187170
今日推荐