2018年5月22日 星期二
2017年2月22日 星期三
2015年9月10日 星期四
Regular Expression
找出含有id的tag
<(.+)( +)id=(('.+')|(".+"))(( +)|(>)|(/>))
HTML標記的正則表達式:
<(\S*?)[^>]*>.*?</\1>|<.*? />
找出<style>表達式:
<(\style)>.*?</\1>
Email地址:
^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
域名:
[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?
InternetURL:
[a-zA-z]+://[^\s]* 或 ^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$
IP地址:
\d+\.\d+\.\d+\.\d+
((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))
xml文件:
^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$
密碼(以字母開頭,長度在6~18之間,只能包含字母、數字和下劃線):
^[a-zA-Z]\w{5,17}$
強密碼(必須包含大小寫字母和數字的組合,不能使用特殊字符,長度在8-10之間):
^(?=.*\d)(?=.*[az])(?=. *[AZ]).{8,10}$
匹配中文字元的正則表達式:
[u4e00-u9fa5]
<(.+)( +)id=(('.+')|(".+"))(( +)|(>)|(/>))
HTML標記的正則表達式:
<(\S*?)[^>]*>.*?</\1>|<.*? />
找出<style>表達式:
<(\style)>.*?</\1>
Email地址:
^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
域名:
[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?
InternetURL:
[a-zA-z]+://[^\s]* 或 ^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$
IP地址:
\d+\.\d+\.\d+\.\d+
((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))
xml文件:
^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$
密碼(以字母開頭,長度在6~18之間,只能包含字母、數字和下劃線):
^[a-zA-Z]\w{5,17}$
強密碼(必須包含大小寫字母和數字的組合,不能使用特殊字符,長度在8-10之間):
^(?=.*\d)(?=.*[az])(?=. *[AZ]).{8,10}$
匹配中文字元的正則表達式:
[u4e00-u9fa5]
2015年7月13日 星期一
window REG batch
新增/修改REG_DWORD語法:
指定登錄編輯程式的版本
[機碼位置]
"登錄值名稱"=登錄值型類型:登錄值內容
範例:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom]
"ZoomDisabled"=dword:00000001
新增/修改REG_SZ語法:
指定登錄編輯程式的版本
[機碼位置]
"登錄值名稱"="登錄值內容"
範例:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"DefaultUserName"="administrator"
"DefaultPassword"="abcdefg"
刪除機碼語法
指定登錄編輯程式的版本
[-機碼位置]
範例:
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\Software\Classes\Dictory\Shell\NewWindow]
指定登錄編輯程式的版本
[機碼位置]
"登錄值名稱"=登錄值型類型:登錄值內容
範例:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom]
"ZoomDisabled"=dword:00000001
新增/修改REG_SZ語法:
指定登錄編輯程式的版本
[機碼位置]
"登錄值名稱"="登錄值內容"
範例:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"DefaultUserName"="administrator"
"DefaultPassword"="abcdefg"
刪除機碼語法
指定登錄編輯程式的版本
[-機碼位置]
範例:
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\Software\Classes\Dictory\Shell\NewWindow]
2015年3月8日 星期日
LDAP語法基礎
= (EQUAL TO)
EX:(givenName=John)
& (logical AND)
EX:(&(givenName=John)(l=Dallas))
! (logical NOT)
EX:(!givenName=John)
* (wildcard)
(givenName=Jo*)
你需要一个filter来找到所有在Dallas或者Austin的对象, 并且first name还得是John. 这个filter应该是:
(&(givenName=John)(|(l=Dallas)(l=Austin)))
你需要找到所有的被disable的user, (msExchUserAccountControl=2) 并且在msExchMasterAccountSID这个属性上没有值.
(&(msExchUserAccountControl=2)(!msExchMasterAccountSID=*))
EX:(givenName=John)
& (logical AND)
EX:(&(givenName=John)(l=Dallas))
! (logical NOT)
EX:(!givenName=John)
* (wildcard)
(givenName=Jo*)
你需要一个filter来找到所有在Dallas或者Austin的对象, 并且first name还得是John. 这个filter应该是:
(&(givenName=John)(|(l=Dallas)(l=Austin)))
你需要找到所有的被disable的user, (msExchUserAccountControl=2) 并且在msExchMasterAccountSID这个属性上没有值.
(&(msExchUserAccountControl=2)(!msExchMasterAccountSID=*))
2015年1月13日 星期二
2014年6月26日 星期四
解決“Device is busy”
原文: http://www.linuxgem.org/tip/use-fuser-rescue-device-is-busy.html
引言:
在Linux下umount掛載的硬碟或者隨身碟的時候,經常會出現“Device is busy”的提示,哦~真讓人惱火,在Windows下的那個無法卸載移動設備的問題,竟然也竄到了Linux下……
其實,錯誤不在WIndows也不在Linux,無法卸載移動設備的原因,是因為系統中還有程序在霸佔著移動設備上的文件,如果冒然強制卸載,可能會導致數據遺失和設備損壞,“Device is busy”是一種保護措施。
既然知道是有程序霸佔,找出這個程序再處理一下就好了。 fuser這個小程序可以派上用場,基本上每個發行版都會帶有fuser這個工具。
fuser可以顯示出當前哪個程序在使用磁盤上的某個文件、掛載點、甚至網路端口,並給出程序進程的詳細訊息。
假設無法卸載的設備為/media/USB,運行下列命令即可:
$ fuser -m -v /media/USB/
用戶進程號權限命令
/media/BAK/: galeki 335 ..c.. gqview
-m參數顯示所有使用指定文件系統的進程,後面可以跟掛載點,或是dev設備( Thanks lisir :),-v參數給出詳細的輸出,可以看出,原來是gqview這個程序還在霸占著移動設備,fuser還給出了程序的進程號,知道了進程號,你就可以隨便怎麼處置這個程序了。
另外你也可以添加一個-k參數:
fuser -m -k /media/USB/
這招自動把霸佔著/media/USB/的程序殺死。如果你不是很明確是否要殺死所有霸佔設備的程序,你還可以加一個-i參數,這樣每殺死一個程序前,都會詢問:
$ fuser -m -v -i -k /media/BAK/
用戶進程號權限命令
/media/BAK/: galeki 371 ..c.. gqview
殺死進程371 ? (y/N)
很順利的解決了“Device is busy”的問題~
引言:
在Linux下umount掛載的硬碟或者隨身碟的時候,經常會出現“Device is busy”的提示,哦~真讓人惱火,在Windows下的那個無法卸載移動設備的問題,竟然也竄到了Linux下……
其實,錯誤不在WIndows也不在Linux,無法卸載移動設備的原因,是因為系統中還有程序在霸佔著移動設備上的文件,如果冒然強制卸載,可能會導致數據遺失和設備損壞,“Device is busy”是一種保護措施。
既然知道是有程序霸佔,找出這個程序再處理一下就好了。 fuser這個小程序可以派上用場,基本上每個發行版都會帶有fuser這個工具。
fuser可以顯示出當前哪個程序在使用磁盤上的某個文件、掛載點、甚至網路端口,並給出程序進程的詳細訊息。
假設無法卸載的設備為/media/USB,運行下列命令即可:
$ fuser -m -v /media/USB/
用戶進程號權限命令
/media/BAK/: galeki 335 ..c.. gqview
-m參數顯示所有使用指定文件系統的進程,後面可以跟掛載點,或是dev設備( Thanks lisir :),-v參數給出詳細的輸出,可以看出,原來是gqview這個程序還在霸占著移動設備,fuser還給出了程序的進程號,知道了進程號,你就可以隨便怎麼處置這個程序了。
另外你也可以添加一個-k參數:
fuser -m -k /media/USB/
這招自動把霸佔著/media/USB/的程序殺死。如果你不是很明確是否要殺死所有霸佔設備的程序,你還可以加一個-i參數,這樣每殺死一個程序前,都會詢問:
$ fuser -m -v -i -k /media/BAK/
用戶進程號權限命令
/media/BAK/: galeki 371 ..c.. gqview
殺死進程371 ? (y/N)
很順利的解決了“Device is busy”的問題~
2014年6月12日 星期四
修改WIFI MAC
1.已ROOT
2.安裝BUSYBOX
3.安裝終端機模擬器 EX:Terminal Emulator
終端機指令: :
su :
busybox iplink show wlan0 (顯示目前無線網卡MAC) :
busybox ifconfig wlan0 hw ether 00:11:22:33:44:55 (改成你要的MAC 上面範例使用00:11:22:33:44:55) busybox iplink show wlan0 (確認修改成果) :
busybox ifconfig 顯示所有網路卡資訊.萬一你的無線網卡不是wlan0 ,照顯示修正. 0是數字. 對了,改完得把Wifi停用再開,就能連線,重開機 ...
2.安裝BUSYBOX
3.安裝終端機模擬器 EX:Terminal Emulator
終端機指令: :
su :
busybox iplink show wlan0 (顯示目前無線網卡MAC) :
busybox ifconfig wlan0 hw ether 00:11:22:33:44:55 (改成你要的MAC 上面範例使用00:11:22:33:44:55) busybox iplink show wlan0 (確認修改成果) :
busybox ifconfig 顯示所有網路卡資訊.萬一你的無線網卡不是wlan0 ,照顯示修正. 0是數字. 對了,改完得把Wifi停用再開,就能連線,重開機 ...
2014年6月10日 星期二
2014年6月9日 星期一
2014 java Develop Day
| 活動日期 | 2014年8月1日(五)8:30~17:30 |
| 活動地點 | 台北國際會議中心101教室(台北市信義路五段一號) |
| 時間 | 議程 | |
|---|---|---|
| 08:30 - 09:30 | 學員報到、攤位參觀 | |
| 09:30 - 09:45 | 歡迎致詞 | 美商甲骨文台灣區總經理 張永慶 美商甲骨文台灣區教育訓練部副總經理 岳汝誠 |
| 09:45 - 10:30 | 主題演講A | ◈
在平板、Pi 以及樂高上的Java8 【Java Technology Ambassador Content Chair, Stephen Chin】 |
| 10:30 - 11:15 | 主題演講B | ◈
Java EE7 最佳實踐:重現古典風 【Java EE/GlassFish evangelist, Oracle, Reza Rahman】 |
| 11:15 - 12:00 | 主題演講C | 解析 JDK8 Functional API【良葛格】 |
| 12:00 - 13:30 | 午餐時間 (用餐場地請上三樓宴會廳) | |
| 時間 | 專家講座 A | 專家講座 B | 專家講座 C | 專家講座 D | 夥伴講座 |
|---|---|---|---|---|---|
| 13:30 - 14:15 | ◈
如何用Lamdba撰寫骨灰遊戲 【Stephen Chin】 |
這些年,我們一起追的 Hadoop 【蘇國鈞】 |
從 SQL 與 Java 為出發點的 NewSQL Database: VoltDB 【陳貽文】 |
Java SE Embedded 開發案例討論 【沈基團】 |
雲端推播技術之Java行動創新應用 【段維瀚】 |
| 14:15 - 14:25 | 中場休息、攤位參觀 | ||||
| 14:25 - 15:10 | ◈
JavaScript/HTML5 - 如何使用Java EE 7 開發更豐富的使用者介面 【Reza Rahman】 |
Make sense of your logs - ElasticSearch & LogStash 【袁孝安】 |
淺談 Java GC 原理、調教和新發展 【陳逸嘉】 |
◈
Java與嵌入式系統 【Naveen Asrani】 |
用TomEE開發Java EE 6 Web Profile應用程式 【潘家羲】 |
| 15:10 - 15:40 | 中場休息、攤位參觀 | ||||
| 15:40 - 16:25 |
Guava 讓程式碼簡潔有力 【李書豪】 |
全文搜尋引擎的進階實作與應用 【王建興】 |
◈
探索 JavaFX 8 【Stephen Chin】 |
淺談 Groovy 與 AWS 雲端應用開發整合 【林彥宏】 |
淺談 Java網路程式應用與開發 【楊恭佑】 |
| 16:25 - 16:35 | 中場休息、攤位參觀 | ||||
| 16:35 - 17:20 | ◈
在 Java EE 中使用 JPA 和 EclipseLink 來操作 NoSQL 【Reza Rahman】 |
Spock:讓你的test生生不息的測試框架 【林世鵬】 |
淺談JavaFX遊戲程式 【黃嘉輝】 |
如何用JDK8實作一個小型的關聯式資料庫系統 【Naoki Kishida】 |
Application vulnerability mitigation on SDLC and case study 【劉寯】 |
| 17:20 - 17:30 | 交流時間、幸運抽獎 | ||||
2014年4月23日 星期三
mysql 基本操作
0.
下載 http://dev.mysql.com/downloads/mysql/ (zip免安裝:Download MySQL Community Server)
啟動 mysqld
管理 mysqladmin
操作 mysql
停止 mysqladmin -u root -p shutdown
1、設定管理帳號:(mysql在安裝後,會建立一個root帳號,不過,沒有密碼)
mysqladmin -u root password abc123 <==設定root帳號,密碼為abc123
2、列出mysql現行環境
mysqladmin variables -u root -p <==使用指令
mysql>show variables; <==使用mysql語法
3、登入資料庫
mysql -u root -p towns <==使用root帳號,登入towns資料庫
mysql -h localhost -u root -p towns <==使用root帳號登入本機端的towns資料庫, 做網路管理時,-h很重要
4、建立資料庫
4.1 mysql -u root -p <==使用root登入mysql
4.2 打入root密碼
4.3 create database towns; <==使用mysql語法,新增towns這個資料庫,“;”一定要加
4.4 mysqladmin -u root create cacti -p <==也可以用指令建立資料庫
5、刪除資料庫
5.1 mysql -u root -p <==使用root登入mysql
5.2 打入root密碼
5.3 drop database towns; <==使用mysql語法,刪除towns這個資料庫,“;”一定要加
6、列出現有資料庫
6.1 mysql -u root -p <==使用root登入mysql
6.1.1 打入root密碼
6.1.2 show databases;
或
6.2 mysql -u root -e "show databases; " -p <==用指令顯示資料庫
6.3 mysqlshow -u root -p <==使用root登入mysql,並列出所有的資料庫
6.2 mysqlshow -u root -p towns <==使用root登入mysql,並列towns資料庫中的資料表
6.3 mysqlshow -u root -p towns towns <==使用root登入mysql,指定towns資料庫,並列出towns資料表
資料來源:http://tsuozoe.pixnet.net/blog/post/21283890
7、匯入資料庫
7.1 需先建立資料庫(如4),可以看一下,dump下來的語法中,是否有下CREATE DATABASE,有就不用建了
7.2 mysql -u root -p abc <'/home/towns/abc/abc.sql' <==將abc.sql匯入abc資料庫中
7.3 如語法中,有下CREATE DATABASE,有就不用建了
7.4. mysql -u root -p <'/home/towns/abc/abc.sql' <==將abc.sql匯入資料庫中(必需有CREATE
DATABASE)
8、匯出資料庫
8.1 資料庫需存在
8.2 mysqldump -u root -p abc >'/home/towns/abc/abc.sql' <==將abc資料庫匯出到abc.sql檔案
8.3 mysqldump -u root -p -d abc > '/home/towns/abc/abc.sql' <==將abc資料庫的結構匯出到abc.sql檔案
9、新增使用者(需先登入mysql server)
9.1 使用grant新增
9.1.1 grant all on abc.* to towns identified by 'abc123' with grant option;
建立towns使用者具有abc完整的管理權,密碼為abc123
9.1.2 grant all on abc.* to towns@localhost identified by 'abc123' with grant option;
建立本機端towns使用者具有abc完整的管理權,密碼為abc123
9.1.3 grant all on *.* to towns@localhost identified by 'abc123' with grant option;
建立本機端towns使用者具有所有資料庫完整的管理權,密碼為abc123
9.1.3.1 grant all on *.* to towns@localhost identified by 'abc123';
與上面的方法相同,獨缺“允許特權”
9.2 使用INSERT
9.3 CREATE USER
--------------------------------------------------------------------------------------------
9.4 變更密碼
9.4.1 grant all on *.* to towns@localhost identified by '123abc' with grant option;
將towns使用者的密碼,由abc123變成123abc
9.4.2 SET PASSWORD FOR 'root'@'localhost.localdomain' = PASSWORD( '*******' )
SET PASSWORD FOR 'root'@'localhost' = PASSWORD( '*******' )
10、刪除使用者
10.1 DELETE FROM mysql.user WHERE User='towns' ;
刪除使用者towns
10.2 DROP USER test@localhost;
11、登入資料庫帳號、密碼常見檔案位置
12、更新資料庫資料(在做任何更動後,建議要使用這指令)
12.1 flush privileges;
??13、在作業系統中,檢查權限之命令
13.1 mysqlaccess localhost user mysql -U root -P abc123 <==檢查user帳號的權限
13.2 mysqlaccess localhost towns abc123 -U root -P abc123 <==檢查towns帳號的權限
13.3 mysqlaccess localhost towns -U root -P <==檢查towns帳號的權限,會要求打入root 密碼
14、權限管理
14.1 grant SELECT,INSERT,UPDATE on abc.* to towns@localhost identified by 'abc123';
開放三種權限(SELECT,INSERT,UPDAT)給towns(本機端)
14.2 開放多個資料庫(abc1、test、abc)給一個帳號(towns)管理,需一條一條加
grant all on abc1.* to towns@localhost identified by 'abc123';
grant all on test.* to towns@localhost identified by 'abc123';
grant all on abc.* to towns@localhost identified by 'abc123';
--------------------------------------------------------------------------------------------
14.3 權限
資料庫(DateBase),十五種權限:
ALL PRIVILEGES、ALTER、CREATE、DELETE、DROP、FILE、INDEX、INSERT、PROCESS、REFERENCES、RELOAD、
SELECT、SHUTDOWN、UPDATE、USAGE
資料表(Table),八種權限:
SELECT、INSERT、UPDATE、DELETE、CREATE、DROP、INDEX、ALTER
資料欄(column),三種權限:
SELECT INSERT UPDATE
修改權限
14.4 REVOKE 權限 ON 資料庫(或資料表TABLE) TO user@host IDENTIFIED BY '密碼';
============================================================================================
GRANT ALL PRIVILEGES ON `abc` . * TO abc@% WITH GRANT OPTION ;
DROP USER towns@';
DROP USER test@localhost';
---------------------------------------------------------------------------------------------
CREATE USER test@localhost IDENTIFIED BY '********';
GRANT USAGE ON * . * TO test@localhost IDENTIFIED BY '********' WITH MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
SET PASSWORD FOR root@localhost = PASSWORD( '*********' ) <==在資料庫中修改密碼方式
16.忘記root密碼處理方式
Linux:
1.使用root登入
2.停止mysql服務(for redhad base)
service mysqld stop
3.使用mysqld_safe指令
mysqld_safe --skip-grant-tables &
此時,會開啟一個安全模式,並停住
4.開新的ssh,用root登入系統
5.使用mysql帳號登入mysql中
6.變更mysql中root密碼
update user set password = password('abc123') where user = 'root';
7.離開mysql
8.重新啟動mysql
9.使用root新密碼登入mysql
-----------------------------------------------------------------------------------------------
Windows:
1.用系統管理員登陸系統。
2.停止MySQL的服務。
3.進入命令視窗,然後進入MySQL的安裝目錄,比如我的安裝目錄是c:\mysql,進入C:\mysql\bin
4.跳過許可權檢查啟動MySQL,
c:\mysql\bin>mysqld-nt --skip-grant-tables
5.重新打開一個視窗,進入c:\mysql\bin目錄,設置root的新密碼
c:\mysql\bin>mysqladmin -u root flush-privileges password "198651"
c:\mysql\bin>mysqladmin -u root -p shutdown
將newpassword替換為你要用的root的密碼,第二個命令會提示你輸入新密碼,重複第一個命令輸入的
密碼。
6.停止MySQL Server,用正常模式啟動Mysql
7.你可以用新的密碼連結到Mysql了。
命令:
net mysql start 啟動MYSQL
net stop mysql 停止MYSQL
下面以在Windows系統上為例,linux上將步驟 4 的mysqld-nt換為safe_mysqld即可
1 、停止mysql5服務:
net stop mysql5
2、開一個DOS視窗執行:
http://www.mscto.com
c:\mysql\bin>mysqld-nt --skip-grant-tables &
3、再開一個DOS視窗執行:
c:\mysql\bin>mysql mysql
> update user set password = password('123456') where user = 'root';
root密碼即為設置為123456!
4、啟動mysql5服務:
net start mysql5
相關資料:http://www.mscto.com/MySQL/20080731665.html
17.顯示目前mysql連線的threads狀態
mysql>show processlist; <==使用mysql語法
mysqladmin processlist -u root -p <==使用指令
===============================================================================================
18.列出MySQL目前的狀態
mysql> show status; <==使用mysql語法
mysqladmin status -u root -p <==使用指令(結果不同)
19.列出mysql的使用者
SELECT User FROM mysql.user Order by User;
帳號管理
mysql中,帳號可設為僅本機使用、僅網路使用、兩者皆可,與mysql安全性有關
mysql>grant all on *.* to towns@localhost identified by 'abc123' with grant option;
利用語法建立towns可以管理所有資料庫、只能本機連線,擁有最大權限
mysql>grant all on *.* to towns@localhost identified by 'abc123';
利用語法建立towns可以管理所有資料庫、只能本機連線,少了grant權限,其他都有
mysql>grant all on *.* to towns@ identified by 'abc123' with grant option;
利用語法建立towns可以管理所有資料庫、能外部及本機連線,擁有最大權限
mysql>grant all on *.* to towns identified by 'abc123' with grant option;
利用語法建立towns可以管理所有資料庫、能外部及本機連線,擁有最大權限
towns@locahost <==只能本機連線
towns@192.168.8.176 <==只能192.168.8.176連線,用於限制帳號連線IP
towns@127.0.0.1 <==只能本機連線
towns@locahost.localdomain <==只能本機連線
towns@ <==不限制連線來源,危險的設定,不過local不能連
towns <==不限制連線來源,危險的設定
註:使用 towns@ 及 towns 在 mysql5 以上的版本會發生仍無法遠端連線,因為 mysql5 以上的版本多加了
兩個特別的帳號,@localhost 及 @[hostname],這兩組帳號在我們設定帳號時,如果沒有給尾巴,會自動加
上去,造成帳號不論local 或 遠端都無法連入
19.1. mysql -e "GRANT ALL PRIVILEGES ON test.* TO test@localhost IDENTIFIED BY 'test' ; "
利用指令來新增帳號
20.資料庫匯出管理
1. 更換資料庫
登入mysql後,選用某個資料庫
mysql> use test; <==連入test資料庫
2 .顯示資料庫的資料表(需先選好資料庫,才能show tables)
mysql> show tables;
mysql -e "use test; show tables; " -p <==直接使用指令下SQL語法,並使用root登入(沒設user預設為
root)
3. 顯示特定資料表中的欄位
mysql> describe table_name;
參考資料:http://www.xspace.idv.tw/bo_blog/read.php?32
21.免密碼登入mysql資料庫(用於資料庫定期備份等……)
1.vim ~/.my.cnf
[client]
password=YOUR_MYSQL_PASSWORD
2.chmod 600 ~/.my.cnf
設定完成後,直接使用mysql -u [user],就可以登入了
資料來源:http://plog.longwin.com.tw/my_note-unix/2009/04/09/mysql-login-backup-script-no-
password-2009
22. 關於帳號問題:當建立最大權限帳號後,該帳號無法本機登入
1. 安裝後系統自動產生的帳號,兩個空白(@localhost、@localhost.localdomain)及三個root
(root@localhost、root@127.0.0.1、root@localhost.localdomain)帳號
2. 此時 root 帳號可以本機登入,不可遠端登入
3. 建立 towns 帳號後(建立最大權限帳號),towns 只能遠端登入,無法本機登入
4. 建立 towns@localhost 帳號,towns 可以本機登入
兩個空白帳號為安全性帳號,當我們使用towns登入時,沒寫完整帳號,會自動帶入@localhost,導致最大權
限帳號無法本機登入,將兩個空白帳號刪除後,最大權限帳號(towns),就可以本機登入了。而這兩個空白
帳號 towns 是透過第三方軟體,才刪除的
23. mysql 連線數設定
Linux 系統:my.cnf 檔中預設並無此參數,需手動加入
設定 /etc/my.cnf
max_connections=100 <==連線上限100
max_user_connections=15 <==使用者連線上限15
也可以設定單一帳號最大連線數,登入mysql後使用語法修改
grant all on *.* to towns with MAX_USER_CONNECTIONS 15 ; <== towns帳號最大連線數為15
windows 系統:在安裝設定時configuration Wizard即有詢問Concurrent Conections,自定值可到1400
設定 C:\Program Files\MySQL\MySQL Server 5.1\my.ini
max_connections=2037 <==連線上限 2037
資料來源:
http://ssorc.tw/rewrite.php/read-639.html
http://kiki.longwin.com.tw/?p=16
24. 使用phpmyadmin 設計資料庫
教學:http://sofree.cc/phpmyadmin-mysql/
25. 改變mysql 預設參數
需修改 /etc/my.cnf檔
例1:變更預設封包大小(max_allowed_packet)
在[mysqld] 下面加入一行
max_allowed_packet = 20M
存檔後,重新啟重mysql
使用mysqladmin variables -u root -p 確認 預設封包值是否已變更
例2:變更資料庫預設語(character_set_server),這個只有mysql 4 才須要改
character_set_server = utf8
存檔後,重新啟重mysql
使用mysqladmin variables -u root -p 確認character_set_server 及 character_set_database 是否變為
utf8
註:不同的下指令方式得到不同的結果
towns 使用 mysqladmin variables -u root -p 出現了以下五個值皆改為UTF8
character_set_client
character_set_connection
character_set_database
character_set_results
character_set_server
towns 登入資料庫後(mysql -u root -p),再使用 show variables;,得到以下結果
character_set_client ==> latin1
character_set_connection ==> latin1
character_set_database ==> utf8
character_set_results ==> latin1
character_set_server ==> utf8
26. 資料庫編碼轉換問題
這個問題只會出現在 mysql 4版中
使用指令 SET NAMES utf8;將character_set_client、character_set_connection、character_set_results
改為 UTF8,這個是臨時性的修改
相關資料:感謝前輩說明 http://chiouss0817.wordpress.com/2006/05/15/internal-charset-
conversion-of-mysql/
27. 免密碼登入mysql
這個在備份時很好用
vim /home/towns/.my.cnf <==建立或編輯.my.cnf檔
[client] <== 加入這兩行,[ ]中是打下密碼
password= [mysql password]
chmod 600 ~/.my.cnf <==調整檔案權限
相關資料:http://blog.longwin.com.tw/2009/04/mysql-login-backup-script-no-password-2009/
28. mysql 效能觀察與調整
相關資料:
http://forum.slime.com.tw/thread208416.html
http://portable.easylife.tw/2074
http://blog.xuite.net/huenlil/note/5877606
29. Mysql UTF-8 中文排序問題
towns在匯資料到Mysql資料庫中,如果欄位資料為中文UTF-8,會出現排序異常的情形,找了一些資料提供大
家參考
1.SELECT * FROM `test` ORDER BY CONVERT(`name` USING big5) DESC
2.
註:DESC為大到小,ASC為小到大
coolhd大的blog http://www.ezdiy.org/forum/viewtopic.php?id=392
KKonline大的blog http://kkonline.pixnet.net/blog/post/34095805-mysql%E4%B8%AD%E7%9A
%84utf8%E4%B8%AD%E6%96%87%E6%8E%92%E5%BA%8F%E7%9A%84%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%A1%88
30.UTF8 table與連線
30.1.table
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`nId` char(10) DEFAULT NULL,
`description` varchar(100) DEFAULT NULL,
`time` time DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
30.2. JDBC連線
String url = "jdbc:mysql://localhost/courses?useUnicode=true&characterEncoding=UTF-8";
String userid = "root";
String userpwd = "root";
Connection con = DriverManager.getConnection(url, userid, userpwd);
下載 http://dev.mysql.com/downloads/mysql/ (zip免安裝:Download MySQL Community Server)
啟動 mysqld
管理 mysqladmin
操作 mysql
停止 mysqladmin -u root -p shutdown
1、設定管理帳號:(mysql在安裝後,會建立一個root帳號,不過,沒有密碼)
mysqladmin -u root password abc123 <==設定root帳號,密碼為abc123
2、列出mysql現行環境
mysqladmin variables -u root -p <==使用指令
mysql>show variables; <==使用mysql語法
3、登入資料庫
mysql -u root -p towns <==使用root帳號,登入towns資料庫
mysql -h localhost -u root -p towns <==使用root帳號登入本機端的towns資料庫, 做網路管理時,-h很重要
4、建立資料庫
4.1 mysql -u root -p <==使用root登入mysql
4.2 打入root密碼
4.3 create database towns; <==使用mysql語法,新增towns這個資料庫,“;”一定要加
4.4 mysqladmin -u root create cacti -p <==也可以用指令建立資料庫
5、刪除資料庫
5.1 mysql -u root -p <==使用root登入mysql
5.2 打入root密碼
5.3 drop database towns; <==使用mysql語法,刪除towns這個資料庫,“;”一定要加
6、列出現有資料庫
6.1 mysql -u root -p <==使用root登入mysql
6.1.1 打入root密碼
6.1.2 show databases;
或
6.2 mysql -u root -e "show databases; " -p <==用指令顯示資料庫
6.3 mysqlshow -u root -p <==使用root登入mysql,並列出所有的資料庫
6.2 mysqlshow -u root -p towns <==使用root登入mysql,並列towns資料庫中的資料表
6.3 mysqlshow -u root -p towns towns <==使用root登入mysql,指定towns資料庫,並列出towns資料表
資料來源:http://tsuozoe.pixnet.net/blog/post/21283890
7、匯入資料庫
7.1 需先建立資料庫(如4),可以看一下,dump下來的語法中,是否有下CREATE DATABASE,有就不用建了
7.2 mysql -u root -p abc <'/home/towns/abc/abc.sql' <==將abc.sql匯入abc資料庫中
7.3 如語法中,有下CREATE DATABASE,有就不用建了
7.4. mysql -u root -p <'/home/towns/abc/abc.sql' <==將abc.sql匯入資料庫中(必需有CREATE
DATABASE)
8、匯出資料庫
8.1 資料庫需存在
8.2 mysqldump -u root -p abc >'/home/towns/abc/abc.sql' <==將abc資料庫匯出到abc.sql檔案
8.3 mysqldump -u root -p -d abc > '/home/towns/abc/abc.sql' <==將abc資料庫的結構匯出到abc.sql檔案
9、新增使用者(需先登入mysql server)
9.1 使用grant新增
9.1.1 grant all on abc.* to towns identified by 'abc123' with grant option;
建立towns使用者具有abc完整的管理權,密碼為abc123
9.1.2 grant all on abc.* to towns@localhost identified by 'abc123' with grant option;
建立本機端towns使用者具有abc完整的管理權,密碼為abc123
9.1.3 grant all on *.* to towns@localhost identified by 'abc123' with grant option;
建立本機端towns使用者具有所有資料庫完整的管理權,密碼為abc123
9.1.3.1 grant all on *.* to towns@localhost identified by 'abc123';
與上面的方法相同,獨缺“允許特權”
9.2 使用INSERT
9.3 CREATE USER
--------------------------------------------------------------------------------------------
9.4 變更密碼
9.4.1 grant all on *.* to towns@localhost identified by '123abc' with grant option;
將towns使用者的密碼,由abc123變成123abc
9.4.2 SET PASSWORD FOR 'root'@'localhost.localdomain' = PASSWORD( '*******' )
SET PASSWORD FOR 'root'@'localhost' = PASSWORD( '*******' )
10、刪除使用者
10.1 DELETE FROM mysql.user WHERE User='towns' ;
刪除使用者towns
10.2 DROP USER test@localhost;
11、登入資料庫帳號、密碼常見檔案位置
12、更新資料庫資料(在做任何更動後,建議要使用這指令)
12.1 flush privileges;
??13、在作業系統中,檢查權限之命令
13.1 mysqlaccess localhost user mysql -U root -P abc123 <==檢查user帳號的權限
13.2 mysqlaccess localhost towns abc123 -U root -P abc123 <==檢查towns帳號的權限
13.3 mysqlaccess localhost towns -U root -P <==檢查towns帳號的權限,會要求打入root 密碼
14、權限管理
14.1 grant SELECT,INSERT,UPDATE on abc.* to towns@localhost identified by 'abc123';
開放三種權限(SELECT,INSERT,UPDAT)給towns(本機端)
14.2 開放多個資料庫(abc1、test、abc)給一個帳號(towns)管理,需一條一條加
grant all on abc1.* to towns@localhost identified by 'abc123';
grant all on test.* to towns@localhost identified by 'abc123';
grant all on abc.* to towns@localhost identified by 'abc123';
--------------------------------------------------------------------------------------------
14.3 權限
資料庫(DateBase),十五種權限:
ALL PRIVILEGES、ALTER、CREATE、DELETE、DROP、FILE、INDEX、INSERT、PROCESS、REFERENCES、RELOAD、
SELECT、SHUTDOWN、UPDATE、USAGE
資料表(Table),八種權限:
SELECT、INSERT、UPDATE、DELETE、CREATE、DROP、INDEX、ALTER
資料欄(column),三種權限:
SELECT INSERT UPDATE
修改權限
14.4 REVOKE 權限 ON 資料庫(或資料表TABLE) TO user@host IDENTIFIED BY '密碼';
============================================================================================
GRANT ALL PRIVILEGES ON `abc` . * TO abc@% WITH GRANT OPTION ;
DROP USER towns@';
DROP USER test@localhost';
---------------------------------------------------------------------------------------------
CREATE USER test@localhost IDENTIFIED BY '********';
GRANT USAGE ON * . * TO test@localhost IDENTIFIED BY '********' WITH MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
SET PASSWORD FOR root@localhost = PASSWORD( '*********' ) <==在資料庫中修改密碼方式
16.忘記root密碼處理方式
Linux:
1.使用root登入
2.停止mysql服務(for redhad base)
service mysqld stop
3.使用mysqld_safe指令
mysqld_safe --skip-grant-tables &
此時,會開啟一個安全模式,並停住
4.開新的ssh,用root登入系統
5.使用mysql帳號登入mysql中
6.變更mysql中root密碼
update user set password = password('abc123') where user = 'root';
7.離開mysql
8.重新啟動mysql
9.使用root新密碼登入mysql
-----------------------------------------------------------------------------------------------
Windows:
1.用系統管理員登陸系統。
2.停止MySQL的服務。
3.進入命令視窗,然後進入MySQL的安裝目錄,比如我的安裝目錄是c:\mysql,進入C:\mysql\bin
4.跳過許可權檢查啟動MySQL,
c:\mysql\bin>mysqld-nt --skip-grant-tables
5.重新打開一個視窗,進入c:\mysql\bin目錄,設置root的新密碼
c:\mysql\bin>mysqladmin -u root flush-privileges password "198651"
c:\mysql\bin>mysqladmin -u root -p shutdown
將newpassword替換為你要用的root的密碼,第二個命令會提示你輸入新密碼,重複第一個命令輸入的
密碼。
6.停止MySQL Server,用正常模式啟動Mysql
7.你可以用新的密碼連結到Mysql了。
命令:
net mysql start 啟動MYSQL
net stop mysql 停止MYSQL
下面以在Windows系統上為例,linux上將步驟 4 的mysqld-nt換為safe_mysqld即可
1 、停止mysql5服務:
net stop mysql5
2、開一個DOS視窗執行:
http://www.mscto.com
c:\mysql\bin>mysqld-nt --skip-grant-tables &
3、再開一個DOS視窗執行:
c:\mysql\bin>mysql mysql
> update user set password = password('123456') where user = 'root';
root密碼即為設置為123456!
4、啟動mysql5服務:
net start mysql5
相關資料:http://www.mscto.com/MySQL/20080731665.html
17.顯示目前mysql連線的threads狀態
mysql>show processlist; <==使用mysql語法
mysqladmin processlist -u root -p <==使用指令
===============================================================================================
18.列出MySQL目前的狀態
mysql> show status; <==使用mysql語法
mysqladmin status -u root -p <==使用指令(結果不同)
19.列出mysql的使用者
SELECT User FROM mysql.user Order by User;
帳號管理
mysql中,帳號可設為僅本機使用、僅網路使用、兩者皆可,與mysql安全性有關
mysql>grant all on *.* to towns@localhost identified by 'abc123' with grant option;
利用語法建立towns可以管理所有資料庫、只能本機連線,擁有最大權限
mysql>grant all on *.* to towns@localhost identified by 'abc123';
利用語法建立towns可以管理所有資料庫、只能本機連線,少了grant權限,其他都有
mysql>grant all on *.* to towns@ identified by 'abc123' with grant option;
利用語法建立towns可以管理所有資料庫、能外部及本機連線,擁有最大權限
mysql>grant all on *.* to towns identified by 'abc123' with grant option;
利用語法建立towns可以管理所有資料庫、能外部及本機連線,擁有最大權限
towns@locahost <==只能本機連線
towns@192.168.8.176 <==只能192.168.8.176連線,用於限制帳號連線IP
towns@127.0.0.1 <==只能本機連線
towns@locahost.localdomain <==只能本機連線
towns@ <==不限制連線來源,危險的設定,不過local不能連
towns <==不限制連線來源,危險的設定
註:使用 towns@ 及 towns 在 mysql5 以上的版本會發生仍無法遠端連線,因為 mysql5 以上的版本多加了
兩個特別的帳號,@localhost 及 @[hostname],這兩組帳號在我們設定帳號時,如果沒有給尾巴,會自動加
上去,造成帳號不論local 或 遠端都無法連入
19.1. mysql -e "GRANT ALL PRIVILEGES ON test.* TO test@localhost IDENTIFIED BY 'test' ; "
利用指令來新增帳號
20.資料庫匯出管理
1. 更換資料庫
登入mysql後,選用某個資料庫
mysql> use test; <==連入test資料庫
2 .顯示資料庫的資料表(需先選好資料庫,才能show tables)
mysql> show tables;
mysql -e "use test; show tables; " -p <==直接使用指令下SQL語法,並使用root登入(沒設user預設為
root)
3. 顯示特定資料表中的欄位
mysql> describe table_name;
參考資料:http://www.xspace.idv.tw/bo_blog/read.php?32
21.免密碼登入mysql資料庫(用於資料庫定期備份等……)
1.vim ~/.my.cnf
[client]
password=YOUR_MYSQL_PASSWORD
2.chmod 600 ~/.my.cnf
設定完成後,直接使用mysql -u [user],就可以登入了
資料來源:http://plog.longwin.com.tw/my_note-unix/2009/04/09/mysql-login-backup-script-no-
password-2009
22. 關於帳號問題:當建立最大權限帳號後,該帳號無法本機登入
1. 安裝後系統自動產生的帳號,兩個空白(@localhost、@localhost.localdomain)及三個root
(root@localhost、root@127.0.0.1、root@localhost.localdomain)帳號
2. 此時 root 帳號可以本機登入,不可遠端登入
3. 建立 towns 帳號後(建立最大權限帳號),towns 只能遠端登入,無法本機登入
4. 建立 towns@localhost 帳號,towns 可以本機登入
兩個空白帳號為安全性帳號,當我們使用towns登入時,沒寫完整帳號,會自動帶入@localhost,導致最大權
限帳號無法本機登入,將兩個空白帳號刪除後,最大權限帳號(towns),就可以本機登入了。而這兩個空白
帳號 towns 是透過第三方軟體,才刪除的
23. mysql 連線數設定
Linux 系統:my.cnf 檔中預設並無此參數,需手動加入
設定 /etc/my.cnf
max_connections=100 <==連線上限100
max_user_connections=15 <==使用者連線上限15
也可以設定單一帳號最大連線數,登入mysql後使用語法修改
grant all on *.* to towns with MAX_USER_CONNECTIONS 15 ; <== towns帳號最大連線數為15
windows 系統:在安裝設定時configuration Wizard即有詢問Concurrent Conections,自定值可到1400
設定 C:\Program Files\MySQL\MySQL Server 5.1\my.ini
max_connections=2037 <==連線上限 2037
資料來源:
http://ssorc.tw/rewrite.php/read-639.html
http://kiki.longwin.com.tw/?p=16
24. 使用phpmyadmin 設計資料庫
教學:http://sofree.cc/phpmyadmin-mysql/
25. 改變mysql 預設參數
需修改 /etc/my.cnf檔
例1:變更預設封包大小(max_allowed_packet)
在[mysqld] 下面加入一行
max_allowed_packet = 20M
存檔後,重新啟重mysql
使用mysqladmin variables -u root -p 確認 預設封包值是否已變更
例2:變更資料庫預設語(character_set_server),這個只有mysql 4 才須要改
character_set_server = utf8
存檔後,重新啟重mysql
使用mysqladmin variables -u root -p 確認character_set_server 及 character_set_database 是否變為
utf8
註:不同的下指令方式得到不同的結果
towns 使用 mysqladmin variables -u root -p 出現了以下五個值皆改為UTF8
character_set_client
character_set_connection
character_set_database
character_set_results
character_set_server
towns 登入資料庫後(mysql -u root -p),再使用 show variables;,得到以下結果
character_set_client ==> latin1
character_set_connection ==> latin1
character_set_database ==> utf8
character_set_results ==> latin1
character_set_server ==> utf8
26. 資料庫編碼轉換問題
這個問題只會出現在 mysql 4版中
使用指令 SET NAMES utf8;將character_set_client、character_set_connection、character_set_results
改為 UTF8,這個是臨時性的修改
相關資料:感謝前輩說明 http://chiouss0817.wordpress.com/2006/05/15/internal-charset-
conversion-of-mysql/
27. 免密碼登入mysql
這個在備份時很好用
vim /home/towns/.my.cnf <==建立或編輯.my.cnf檔
[client] <== 加入這兩行,[ ]中是打下密碼
password= [mysql password]
chmod 600 ~/.my.cnf <==調整檔案權限
相關資料:http://blog.longwin.com.tw/2009/04/mysql-login-backup-script-no-password-2009/
28. mysql 效能觀察與調整
相關資料:
http://forum.slime.com.tw/thread208416.html
http://portable.easylife.tw/2074
http://blog.xuite.net/huenlil/note/5877606
29. Mysql UTF-8 中文排序問題
towns在匯資料到Mysql資料庫中,如果欄位資料為中文UTF-8,會出現排序異常的情形,找了一些資料提供大
家參考
1.SELECT * FROM `test` ORDER BY CONVERT(`name` USING big5) DESC
2.
註:DESC為大到小,ASC為小到大
coolhd大的blog http://www.ezdiy.org/forum/viewtopic.php?id=392
KKonline大的blog http://kkonline.pixnet.net/blog/post/34095805-mysql%E4%B8%AD%E7%9A
%84utf8%E4%B8%AD%E6%96%87%E6%8E%92%E5%BA%8F%E7%9A%84%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%A1%88
30.UTF8 table與連線
30.1.table
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`nId` char(10) DEFAULT NULL,
`description` varchar(100) DEFAULT NULL,
`time` time DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
30.2. JDBC連線
String url = "jdbc:mysql://localhost/courses?useUnicode=true&characterEncoding=UTF-8";
String userid = "root";
String userpwd = "root";
Connection con = DriverManager.getConnection(url, userid, userpwd);
2014年1月7日 星期二
format 3TB external HD in winXP
1.將外接硬碟接到Window XP上
2.[開始]->[執行]->輸入[cmd]
3.輸入[diskpart]->輸入[list disk]->(記住磁碟代號)
->輸入[select disk 磁碟代號]->輸入[clean]->輸入[exit]兩次
4.[我的電腦]按右鍵->選[管理]->選[磁碟管理]->出現磁碟轉換精靈->下一步 > 下一步 > 完成
5.在[磁碟管理]選擇要建立partition硬碟->右鍵選[New Partition]->下一步直到完成
orign from http://badgerandblade.com/vb/showthread.php/312523-Using-3TB-external-drives-with-Windows-XP-32-bit
I just wasted hours after impulse buying a 3TB external drive only to find it wasn't recognized by my XP machines. Trying to find a straight answer to whether they can work together was near impossible.
The answer is yes. The 5 minute fix was to use diskpart to clear the GPT partition table, then on an XP machine initialize the disk (as MBR style) then create one big partition/drive. Because the disk presents itself as having 4K sectors instead of the standard 512 byte ones, the 2TB limit of XP is raised to (presumably) 16TB.
orign from:How to correctly format this drive for use under Windows XP
If you mess things up by trying to connect the drive directly instead of through the included adapter, and end up with multiple partitions etc., here's how to fix things:
This must be done under Windows XP. If it is done under Windows 7, then things will work under Windows 7 but will not work under Windows XP, look, there is no drive letter under Windows XP:
So you can only use the drive under Windows XP if you:
1. Put the adapter back on and connect it through the adapter.
2. Go to Windows XP DOS [if Windows Vista/7 DOS is used, then the drive will not be visible under Windows XP.]
• diskpart
• list disk
• select disk #
[of the External Drive]
• clean
• exit
• exit
Right click on My Computer in Windows XP > Manage > Disk Management > Initialize and Convert Disk Wizard will pop up >
Next > Next > Finish
Scroll down to the Disk # of the drive and Right Click on where it says Unallocated > New Partition... >
Next > Next > Next > Next > Next > Finish
[You can assign different drive letter or drive name if you wish before clicking on Next. Quick format will take less than a minute, Long Format will take hours and hours but is recommended initially to make sure there are no problems with the drive.]
I am assuming we should leave the Allocation unit size on Default but I did a quick format under Windows XP then rebooted into Windows 7 where I did a long format under Windows 7 using the 4096 byte Allocation unit size.
P.S. If you don't have My Computer under Windows XP - here's the long way to get to Disk Management:
Windows XP > Control Panel > Administrative Tools > Computer Management > Storage > Disk Management
2.[開始]->[執行]->輸入[cmd]
3.輸入[diskpart]->輸入[list disk]->(記住磁碟代號)
->輸入[select disk 磁碟代號]->輸入[clean]->輸入[exit]兩次
4.[我的電腦]按右鍵->選[管理]->選[磁碟管理]->出現磁碟轉換精靈->下一步 > 下一步 > 完成
5.在[磁碟管理]選擇要建立partition硬碟->右鍵選[New Partition]->下一步直到完成
orign from http://badgerandblade.com/vb/showthread.php/312523-Using-3TB-external-drives-with-Windows-XP-32-bit
I just wasted hours after impulse buying a 3TB external drive only to find it wasn't recognized by my XP machines. Trying to find a straight answer to whether they can work together was near impossible.
The answer is yes. The 5 minute fix was to use diskpart to clear the GPT partition table, then on an XP machine initialize the disk (as MBR style) then create one big partition/drive. Because the disk presents itself as having 4K sectors instead of the standard 512 byte ones, the 2TB limit of XP is raised to (presumably) 16TB.
orign from:How to correctly format this drive for use under Windows XP
If you mess things up by trying to connect the drive directly instead of through the included adapter, and end up with multiple partitions etc., here's how to fix things:
This must be done under Windows XP. If it is done under Windows 7, then things will work under Windows 7 but will not work under Windows XP, look, there is no drive letter under Windows XP:
So you can only use the drive under Windows XP if you:
1. Put the adapter back on and connect it through the adapter.
2. Go to Windows XP DOS [if Windows Vista/7 DOS is used, then the drive will not be visible under Windows XP.]
• diskpart
• list disk
• select disk #
[of the External Drive]
• clean
• exit
• exit
Right click on My Computer in Windows XP > Manage > Disk Management > Initialize and Convert Disk Wizard will pop up >
Next > Next > Finish
Scroll down to the Disk # of the drive and Right Click on where it says Unallocated > New Partition... >
Next > Next > Next > Next > Next > Finish
[You can assign different drive letter or drive name if you wish before clicking on Next. Quick format will take less than a minute, Long Format will take hours and hours but is recommended initially to make sure there are no problems with the drive.]
I am assuming we should leave the Allocation unit size on Default but I did a quick format under Windows XP then rebooted into Windows 7 where I did a long format under Windows 7 using the 4096 byte Allocation unit size.
P.S. If you don't have My Computer under Windows XP - here's the long way to get to Disk Management:
Windows XP > Control Panel > Administrative Tools > Computer Management > Storage > Disk Management
訂閱:
文章 (Atom)