mysql 基本操作
更新時間:2012年08月10日 11:08:08 作者:
早打算寫些關(guān)于數(shù)據(jù)庫操作方面的知識了,現(xiàn)在終于完成了第一篇,以下記錄了關(guān)于mysql操作方面的基礎(chǔ)知識
在window下,啟動、停止mysql服務
啟動mysql數(shù)據(jù)庫
net start mysql
停止mysql數(shù)據(jù)庫
net stop mysql
重新啟動mysql數(shù)據(jù)庫
net restart mysql
命令行形式,mysql基本命令的使用
1、命令的取消
\c
2、退出mysql窗口
exit;或quit;或ctrl+c
3、查看數(shù)據(jù)庫版本號
select version();
4、顯示當前存在的數(shù)據(jù)庫
show databases;
5、選擇test數(shù)據(jù)庫
use test;
6、查看選擇的數(shù)據(jù)庫
select database();
7、設(shè)置數(shù)據(jù)庫中文編碼
set names utf8;
8、創(chuàng)建一個test數(shù)據(jù)庫
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號降序輸出
select * from mtest order by id desc;
13、顯示第11至20條數(shù)據(jù)信息
select * from mtest id limit 10,10;
啟動mysql數(shù)據(jù)庫
net start mysql
停止mysql數(shù)據(jù)庫
net stop mysql
重新啟動mysql數(shù)據(jù)庫
net restart mysql
命令行形式,mysql基本命令的使用
1、命令的取消
\c
2、退出mysql窗口
exit;或quit;或ctrl+c
3、查看數(shù)據(jù)庫版本號
select version();
4、顯示當前存在的數(shù)據(jù)庫
show databases;
5、選擇test數(shù)據(jù)庫
use test;
6、查看選擇的數(shù)據(jù)庫
select database();
7、設(shè)置數(shù)據(jù)庫中文編碼
set names utf8;
8、創(chuàng)建一個test數(shù)據(jù)庫
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號降序輸出
select * from mtest order by id desc;
13、顯示第11至20條數(shù)據(jù)信息
select * from mtest id limit 10,10;
相關(guān)文章
MySQL中的自定義函數(shù)(CREATE FUNCTION)
這篇文章主要介紹了MySQL中的自定義函數(shù)(CREATE FUNCTION),具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-06-06
MySQL數(shù)據(jù)庫中case表達式的用法示例
這篇文章主要介紹了MySQL數(shù)據(jù)庫中case表達式用法的相關(guān)資料,MySQL的CASE表達式用于條件判斷,返回不同結(jié)果,適用于SELECT、UPDATE和ORDERBY,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2025-02-02
mysql安裝報錯unknown?variable?‘mysqlx_port=0.0‘簡單解決過程
這篇文章主要給大家介紹了關(guān)于mysql安裝報錯unknown?variable?‘mysqlx_port=0.0‘的解決過程,文中通過代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考借鑒價值,需要的朋友可以參考下2024-08-08

