mysql資料庫的基礎知識

2021-06-23 03:50:51 字數 3472 閱讀 1823

,視窗不要關閉就可以了,從程序中可以看到mysqld.exe在執行,再開啟乙個dos視窗,c:\mysql\bin>mysqladmin -uroot -p shutdown,提示輸入資料庫的root密碼,輸入後就可以關閉mysql服務程序了。然後c:\mysql\bin>mysql -uroot -p

提示輸入口令,直接就可以最簡單的方式啟動乙個mysql的客戶端程式,登入之後提示符變為mysql>   然後用mysql>set password for root@localhost =password('tqv311');   設定root的口令,mysql>quit退出,c:\mysql\bin>mysql -hlocalhost -uroot -ptqv311 重新啟動mysql客戶端程式並以root的身份連線本地mysql例項,此時沒有使用任何資料庫。mysql>show databases;顯示當前所有的資料庫,mysql>use mysql;使用mysql資料庫作為當前資料庫,mysql>quit 再用c:\mysql\bin>mysql -hlocalhost -uroot -ptqv311 gjj 就直接設定gjj為當前的資料庫了,用mysql>select user( );select database( )可以檢視當前使用者和當前正在使用的資料庫(以後用database代表資料庫)。轉入正題,怎麼學呢?先學什麼?首先要明白學的東西有什麼基礎內容,比如mysql是資料庫,伺服器和客戶端的安裝、客戶端到伺服器的連線、資料庫的基本概念(例項、資料庫、使用者、表及索引、引擎)要先完成,要明白自己在幹什麼,所做工作的成果怎麼才能檢視到。這些前期工作一定要有耐心,除非你不想真正的學好它,否則用十天的時間完成以上的內容都是完全有可能的。具體到要學的mysql,可以看一下基本的入門書,然後使用mysql這個自帶的客戶端,千萬不要用帶介面的客戶端,很快你就會被各種各樣的麻煩困擾。就用mysql客戶端,努力學好使用方法,用兩天時間看能不能學的差不多,首先mysql>help contents;檢視說明,乙個乙個看一下。

前面是講了一些怎麼快速建立乙個環境,這一段把這幾天摸索的mysql客戶端命令梳理一下。首先,mysql>help contents;  mysql>show  plugins;  先看一下type為storage engine的行(怎麼能只列出這些行),知道有哪些引擎可以用就可以了。然後mysql>help;  有個tee,mysql>tee c:\mysql\tee.txt   (注意這裡不能有冒號)後面的命令和結果都會附加到這個檔案;mysqls>notee;  停止記錄,在另乙個dos視窗c:\mysql>cd .>tee.txt  清空tee.txt ,mysql>tee;再次啟用tee.txt記錄。c:\mysql>type tee.txt檢視內容。【傳送到桌面快捷設定快捷鍵ctrl+shift+alt+t開啟,虛擬機器中ctrl+alt後,ctrl+shift+alt+c開啟有道詞典mini視窗】,mysql>show create table tables

nformation_schema>select * from global_variables where variable_name like 'char%';
information_schema>select * from global_variables where variable_name like '%dir%'; information_schema>select * from global_variables where variable_name like '%dir%';

information_schema>select * from schemata;

nformation_schema>select * from global_variables where variable_name like 'char%';

information_schema>select * from global_variables where variable_name like '%dir%'; information_schema>select * from global_variables where variable_name like '%dir%';information_schema>select * from schemata;

如何檢視伺服器中的所有表的內容呢?mysql> select table_schema,table_name from tables into outfile 'z:\mysql\\outfiletest4.txt' fields terminated by '\.' enclosed by '' optionally enclosed by '' lines terminated by '\;\r\n' starting by 'select * from ';(注意目錄用雙斜線)然後mysql> source z:\mysql\outfiletest4.txt(注意目錄用單斜線)

select table_schema,table_name from tables into outfile 'z:\mysql\\outfiletest4.txt' fields terminated by '\.' enclosed by '' optionally enclosed by '' lines terminated by '\;\r\n' starting by 'select * from ';

select * from information_schema.tables
用mysqld啟動時,--help可以使這個命令只顯示幫助,並不啟動mysqld,你把這一句放在my.ini中的mysqld中的第一句,如果沒有啟動,只列出了幫助資訊,就可以確定使用了這個my.ini。

這一段講一下編碼問題,首先要搞清楚字符集和編碼,網上很多,mysql中的character set用mysql>show variables like 'char%';collation用mysql>show variables like 'collation%';同時指明了character或collation的預設值,其中system是metadata的字符集,(win下的是utf8,確保各種語言都可用,是編譯時確定的嗎?)

sever和client的在my.ini中確定,[mysqld] character-set-server=utf8  collation-server=utf8_general_ci  [client] default-character-set=utf8 。server,database,table,columns按順序整合上一層物件的,connection、result隨著client變化。_ci不分大小寫,_cs和_bin分大小寫,最好是指定sever和client為utf8後,建立其他物件時不要再指定,這樣就統一了,在windows下的mysql命令列下,直接輸入命令時,漢字都是用的client字符集,用sourceset names 'ascii' 可以改變client的字符集。gvim編輯中,:e ++enc=utf-8 該命令會重新用

utf-8

編碼來開啟之前開啟的檔案。:set fenc=utf-8 該命令修改當前檔案編碼,:w後儲存成該編碼的檔案。

資料庫基礎知識 mysql

按照資料結構來組織 儲存和管理資料的倉庫,其本身可看作電子化的檔案櫃,使用者可以對檔案中的資料進行增加 刪除 修改 查詢等操作資料庫 資料庫管理系統 關係型資料庫 mysql oracle oracale mssql access excel,mysofeware db2 ibm sqllite 輕...

Mysql資料庫基礎知識

用於記錄所學資料庫 mysql 的基礎知識。mysql是乙個單程序多執行緒 支援多使用者 基於客戶機 伺服器 client server簡稱c s 的關聯式資料庫管理系統 結構化查詢語言 structured query language db dbs dbms dba db資料庫 dbs資料庫系統...

MySQL資料庫基礎知識

一 database server 資料庫伺服器,專用於儲存網頁中的資料。1 關係型資料庫管理系統分為兩部分 伺服器端 負責永久儲存資料 維護資料,人不能直接 伺服器上資料的邏輯結構 server database table row column 客戶端 用於向伺服器發起 增刪改查 命令,呈現出操...