mysql常用命令

來源:互聯網
上載者:User

標籤:mysql常用命令

引擎

MyISAM強調的是效能,比InnoDB快,但不提供事務支援,複雜的任務,關聯。支援表鎖。類似excel表格。安裝時預設模式。

InnoDB,支援外部鍵,可以執行大量的insert和update,像銀行系統

 

兩個引擎,類似apache兩個工作模式

Database庫>tables表>row行

MyISAM 類型的表強調的是效能,主要用於select(查詢)操作,執行速度比InnoDB類型的錶快,但不提供事務支援。支援表鎖

InnoDB類的表提供事務支援,適合複雜的邏輯關係,執行大量的insert和update。支援行鎖。

常用命令

mysql -e"show databases;"終端外執行mysql命令

create database juedu character set utf8;增加庫或charset=utf8

use jfedu;使用庫

show tables;預覽表

drop table class6;刪除表

delete from class6;清空表內容

delete from class6 where name=’yinxing’;刪除指定行

create table class6 (name char(10),age char(10),job char(10));建立表

其中char是必須設定的,設定成varchar

select * from class6 where name=’yinxing’;查表limit 5;只看5行

加and age=20;加and job=’IT’;

把*改成name,只查name那一列

select count(*) from class6;看錶一共幾行


describe(縮寫成desc) class6;看錶的結構

show create table class6; 看錶建立的語句,看引擎,看字元集

show engines;可以看到所有模式,看到MyISAM是預設default

show variables;顯示mysql參數

show variables like “%char%”; 看字元集,看一遍然後全改成utf8

vi /etc/my.conf

[client]欄位裡加入  default-character-set=utf8

[mysqld]欄位裡加入character-set-server=utf8

[mysql]欄位裡加入  default-character-set=utf8

然後重啟MySQL服務即可。


資料庫授權

grant all(SELECT,INSERT,UPDATE,DELETE普通資料使用者資料庫中所有表資料的權利  create,alter,drop資料庫開發人員MySQL 資料表結構許可權,增刪改查,設定成select只有select許可權,給開發看就只給select許可權,多許可權逗號隔開) on *.* to [email protected]’192.168.245.128’ identified by “1”;

重新整理許可權mysql>flush privileges;

撤銷授權 revoke from  revoke all on *.* from [email protected];

mysql常用命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.