0.安裝MySQL服務
1.[不同端口登錄]
通過開始菜單-> 程序-> MySQL-> MySQL Command Line Client
通過輸入密碼Enter password:******進行登錄 該MySQL服務端口已定
或者
通過運行命令->C:\Program Files\MySQL\MySQL Server 5.2\bin>
然后利用mysql進行登錄
C:\Program Files\MySQL\MySQL Server 5.2\bin>mysql -uroot -h127.0.0.1 -P3307 -p
Enter password:******
亦可選擇登錄遠程MySQL
2.[執(zhí)行SQL文件]
創(chuàng)建測試數據庫及數據表
mysql> source c:/test/test.sql;
test.sql文件內容:
create database IF NOT EXISTS testdb;
use testdb;
create table testtable
(testName varchar(10));
3.[創(chuàng)建用戶]
mysql> create user testuser identified by 'testpass';
4.[賦予權限]
mysql> grant all privileges on testdb.* to 'testuser'@'%' identified by 'testpass';
5.[修改root密碼](轉自網絡)
如果已登錄
1)use mysql
2)update user set password=password('你的密碼') where user='root';
3)flush privileges;
如果沒登錄,你想進數據庫而沒有密碼
先關掉服務
然后以safe模式進入
mysqld_safe --skip-grant-tables &
這個窗口不要關,這樣進數據庫就不用密碼,進去后 做 “如果已登錄”的 步驟