mysql 基本操作
更新時(shí)間:2012年08月10日 11:08:08 作者:
早打算寫些關(guān)于數(shù)據(jù)庫(kù)操作方面的知識(shí)了,現(xiàn)在終于完成了第一篇,以下記錄了關(guān)于mysql操作方面的基礎(chǔ)知識(shí)
在window下,啟動(dòng)、停止mysql服務(wù)
啟動(dòng)mysql數(shù)據(jù)庫(kù)
net start mysql
停止mysql數(shù)據(jù)庫(kù)
net stop mysql
重新啟動(dòng)mysql數(shù)據(jù)庫(kù)
net restart mysql
命令行形式,mysql基本命令的使用
1、命令的取消
\c
2、退出mysql窗口
exit;或quit;或ctrl+c
3、查看數(shù)據(jù)庫(kù)版本號(hào)
select version();
4、顯示當(dāng)前存在的數(shù)據(jù)庫(kù)
show databases;
5、選擇test數(shù)據(jù)庫(kù)
use test;
6、查看選擇的數(shù)據(jù)庫(kù)
select database();
7、設(shè)置數(shù)據(jù)庫(kù)中文編碼
set names utf8;
8、創(chuàng)建一個(gè)test數(shù)據(jù)庫(kù)
create database test
9、創(chuàng)建一張mtest表
create table mtest(
id tinyint(2) unsigned not null auto_increment,
name varchar(20),
sex char(1),
email varchar(50),
birth datetime,
primary key (id)
);
10、向mtest表中插入一條數(shù)據(jù)
insert into mtest(`name`,`sex`,`email`,`birth`) values ('zhangsan','1','zhangsan@163.com',now());
11、查詢mtest表中name為張三的信息
select * from mtest where name='zhangsan';
12、按照id號(hào)降序輸出
select * from mtest order by id desc;
13、顯示第11至20條數(shù)據(jù)信息
select * from mtest id limit 10,10;
啟動(dòng)mysql數(shù)據(jù)庫(kù)
net start mysql
停止mysql數(shù)據(jù)庫(kù)
net stop mysql
重新啟動(dòng)mysql數(shù)據(jù)庫(kù)
net restart mysql
命令行形式,mysql基本命令的使用
1、命令的取消
\c
2、退出mysql窗口
exit;或quit;或ctrl+c
3、查看數(shù)據(jù)庫(kù)版本號(hào)
select version();
4、顯示當(dāng)前存在的數(shù)據(jù)庫(kù)
show databases;
5、選擇test數(shù)據(jù)庫(kù)
use test;
6、查看選擇的數(shù)據(jù)庫(kù)
select database();
7、設(shè)置數(shù)據(jù)庫(kù)中文編碼
set names utf8;
8、創(chuàng)建一個(gè)test數(shù)據(jù)庫(kù)
create database test
9、創(chuàng)建一張mtest表
create table mtest(
id tinyint(2) unsigned not null auto_increment,
name varchar(20),
sex char(1),
email varchar(50),
birth datetime,
primary key (id)
);
10、向mtest表中插入一條數(shù)據(jù)
insert into mtest(`name`,`sex`,`email`,`birth`) values ('zhangsan','1','zhangsan@163.com',now());
11、查詢mtest表中name為張三的信息
select * from mtest where name='zhangsan';
12、按照id號(hào)降序輸出
select * from mtest order by id desc;
13、顯示第11至20條數(shù)據(jù)信息
select * from mtest id limit 10,10;
您可能感興趣的文章:
相關(guān)文章
MySQL 5.7臨時(shí)表空間如何玩才能不掉坑里詳解
這篇文章主要給大家介紹了關(guān)于MySQL 5.7臨時(shí)表空間如何玩才能不掉坑里的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用mysql具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起看看吧2018-09-09MySQL自動(dòng)停機(jī)的問(wèn)題處理實(shí)戰(zhàn)記錄
這篇文章主要給大家介紹了關(guān)于MySQL自動(dòng)停機(jī)的問(wèn)題處理,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用MySQL具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05打開和關(guān)閉mysql服務(wù)的兩種實(shí)現(xiàn)方法
這篇文章主要介紹了打開和關(guān)閉mysql服務(wù)的兩種實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07MySQL5.6解壓版服務(wù)無(wú)法啟動(dòng)之系統(tǒng)錯(cuò)誤1067問(wèn)題
這篇文章主要介紹了MySQL5.6解壓版服務(wù)無(wú)法啟動(dòng)—系統(tǒng)錯(cuò)誤1067問(wèn)題及解決方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08Mac OS10.11下mysql5.7.12 安裝配置方法圖文教程
這篇文章主要為大家詳細(xì)介紹了Mac OS10.11下mysql5.7.12 安裝配置方法圖文教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01Mysql 日期時(shí)間 DATE_FORMAT(date,format)
Mysql 日期時(shí)間 DATE_FORMAT(date,format) ,需要的朋友可以參考下。2010-12-12mysql中text,longtext,mediumtext區(qū)別小結(jié)
在 MySQL 中,text、mediumtext 和 longtext 都是用來(lái)存儲(chǔ)大量文本數(shù)據(jù)的數(shù)據(jù)類型,本文就來(lái)詳細(xì)的介紹一下這三種類型的區(qū)別,具有一定的參考價(jià)值,感興趣的可以了解一下2023-12-12