第一篇:mysql問題解決總結(jié)
MySql問題解決總結(jié)
ERROR 1045(28000): Access denied for user 'root'@'localhost'(using password: YES)ERROR 1045(28000): Access denied for user 'root'@'localhost'(using password: NO)
這種問題就是mysql密碼需要重置; 重置方式:
1.打開/etc/mysql/debian.cnf文件,里面存儲(chǔ)了相關(guān)的密碼,我的文件信息如下
sudovi /etc/mysql/debian.cnf# Automatically generated for Debian scripts.DO NOT TOUCH![client] host = localhost user = debian-sys-maint password = 6x1XG2B5p75WtFV2 socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = 6x1XG2B5p75WtFV2 socket = /var/run/mysqld/mysqld.sock basedir = /usr 在[client]段有user=以及password=這兩行,這就是通過apt-get安裝mysql,系統(tǒng)給我們?cè)O(shè)置的mysql登錄名和密碼
2.輸入命令: mysql-udebian-sys-maint-pdebian-sys-maint即debian.cnf中user=后面的內(nèi)容.回車后會(huì)提示輸入密碼,此時(shí)把password=后面的內(nèi)容復(fù)制粘貼后回車即可進(jìn)行mysql 控制臺(tái)
3.進(jìn)入控制臺(tái)后.按以下步驟進(jìn)行: use mysql;update user set password=PASSWORD('新密碼')where user='root';FLUSH PRIVILEGES;此時(shí)可以輸入quit;退出后用root帳號(hào)登錄,也可以繼續(xù)其他操作.
第二篇:mySql總結(jié)
Mysql命令:在mysql的bin目錄下執(zhí)行: Mysql –h host_name –u user_name –p password Use 數(shù)據(jù)庫名;選定默認(rèn)數(shù)據(jù)庫(切換數(shù)據(jù)庫)查詢當(dāng)前使用的數(shù)據(jù)庫:select database(); Show databases;顯示所有數(shù)據(jù)庫;
Show tables ;顯示默認(rèn)數(shù)據(jù)庫下的所有表; Show status;顯示服務(wù)器狀態(tài)信息 c;放棄正在輸入的命令; h;顯示命令清單;
s;顯示mysql服務(wù)器狀態(tài)信息; q;退出mysql;
Describe 表名:查看表結(jié)構(gòu);
檔案柜相當(dāng)于數(shù)據(jù)庫,抽屜相當(dāng)于表,抽屜中的文件相當(dāng)于記錄;
0x:加1到9的數(shù)字或者a到f就可以構(gòu)成16進(jìn)制了。注意零x中的x不能大寫。字符串:?jiǎn)我?hào)或者雙引號(hào)引起來的都是字符串; Tinyint是1字節(jié); Smallint是2字節(jié); Mediumint是3字節(jié); Int是4字節(jié) Bigint是8字節(jié); 刪除主表前,先刪除子表。選擇主鍵的原則:
1)最少性:盡量選擇單個(gè)鍵做為主鍵
2)穩(wěn)定性:盡量選擇數(shù)值更新少的列作為主鍵。查看自定義函數(shù)創(chuàng)建信息:
Show create function function_name;類型總結(jié):
Tinyint :占一個(gè)字節(jié),它的范圍是-128到127 Smallint:占2個(gè)字節(jié),它的范圍是-2的15次方到2的15次方減一; Mediumint:占3個(gè)字節(jié),它的范圍是-2的23次方到2的23次方減一; Int:占4個(gè)字節(jié),它的范圍是-2的31次方到2的31次方減一; Bigint:占8個(gè)字節(jié),它的范圍是-2的63次方到2的63次方減一; Float:占4個(gè)字節(jié) Double:占8個(gè)字節(jié)
Decimal(m,n):占m個(gè)字節(jié); Char(10)和char(10 char)是一樣的;
數(shù)值列的完整性約束講解:
Auto increment(自動(dòng)標(biāo)識(shí)列):在需要產(chǎn)生唯一標(biāo)示符號(hào)或者順序值的時(shí)候,可用此屬性。值從1開始,一般在插入null到auto increment列時(shí),mysql會(huì)插入比當(dāng)前列最大值大1的值。一個(gè)表中最多能有一個(gè)此屬性的列。對(duì)于想使用此屬性的列應(yīng)該定義為not null,并定義為primary key或者定義為unique。
Null 和not null:默認(rèn)是null,如果在插入數(shù)據(jù)時(shí),指定了not null,那么在插入數(shù)據(jù)時(shí)必須要在此字段插入數(shù)據(jù)。如果指定了null ,那么在插入數(shù)據(jù)時(shí),如果沒有給此字段插入數(shù)據(jù),此字段就插入null.mysql-h host-u user-p menagerie 注意,剛才顯示的命令行中的menagerie不是你的 密碼。如果你想要在命令行上在-p選項(xiàng)后提供 密碼,則不能插入空格(例如,如-pmypassword,不是-p mypassword)。但是,不建議在命令行輸入密碼,因?yàn)檫@樣會(huì)暴露 密碼,能被在機(jī)器上登錄的其它用戶窺探到。
查詢當(dāng)前日期:使用curdate()函數(shù),任何表都可以的。Select curdate()from cjym;可以通過year,month,day獲取它的年月日。Select year(curdate())from cjym;Select month(curdate())from cjym;Select day(curdate())from cjym;Mysql中的_和%表示單個(gè)字符和零個(gè)或者多個(gè)字符; 有l(wèi)ike 和not like比較操作符;
要想找出你的服務(wù)器支持哪個(gè)存儲(chǔ)引擎,執(zhí)行下面的語句: Show engines;Select 1/7;都可以; 日期和時(shí)間類型: Time :時(shí)間; Date:日期;
Datetime:日期和時(shí)間; 創(chuàng)建表:
Create table student(Student_id int(10)not null primary key auto_increment, Student_name varchar(20));注意在創(chuàng)建表的時(shí)候,如果是手動(dòng)寫sql語句的時(shí)候自動(dòng)標(biāo)示符要寫這樣的 auto_increment;有個(gè)下劃線; 更改表結(jié)構(gòu)操作:
給表添加一條字段:在最前面加字段用first,在最后面加用after;默認(rèn)在最后加; Alter table student add age int first;給表設(shè)定默認(rèn)值:
Alter table student alter column_name set default default_value;給表中的字段添加主鍵;如果主鍵存在則出現(xiàn)錯(cuò)誤; Alter table student add primary key(column_name);刪除表中的一列:
Alter table student drop column_name;刪除表中的主鍵: Alter table student drop primary key;更改表的名字:
Alter table student rename as new_tablename;修改表中的字段類型: Alter table student modify sno int;運(yùn)算符:
Between。。and用于檢驗(yàn)一個(gè)值(一個(gè)求值表達(dá)式)是否存在一個(gè)指定的范圍內(nèi);
Select 10 between 1 and 100;結(jié)果是1:表示是真的;
In 用于檢驗(yàn)一個(gè)值(一個(gè)表達(dá)式)是否包含在一個(gè)指定的集合中。
Select 2 in(1,2,3,4,5,6),’a’ in(‘b’,’e’,.’h’);結(jié)果顯示1和0;1表示真,0表示假;
Is null和is not null來測(cè)定是否為空;
特殊的運(yùn)算符:<=>:mysql稱它為null安全的等于; Select null=null,null< = >null;結(jié)果顯示null和1; Regexp運(yùn)算符; Mysql中的元字符;
邏輯運(yùn)算符:and(&&),or(||),not(!)插入數(shù)據(jù)時(shí),插入多行值時(shí):
插入多行數(shù)據(jù): Insert into 表名(列名)Select 列名 From 表名;
更改記錄的操作語法格式:
Update 表名 set 列名=更新值 [where 更新條件] 刪除記錄的操作格式:
Delete from 表名 [where 刪除條件]; 表和字段的引用方式有兩種: 絕對(duì)引用:數(shù)據(jù)庫名.表名(.字段名);相對(duì)引用:表名.(字段名); Where子句使用的謂詞:
Between。。and。。在兩數(shù)之間 Not between ….and ….不在兩數(shù)之間 In:是否在特定的集合里。Not in :與上面相反。Like:是否匹配一個(gè)模式;
Regexp:檢查一個(gè)值是否匹配一個(gè)常規(guī)表達(dá)式; 復(fù)制表:
Create table student select name,age from stu;復(fù)制表后,表中的字段和stu表中的字段一樣并且記錄數(shù)也是存在的;
學(xué)習(xí)地址:http://
Mysql的存儲(chǔ)過程: Create procedure p()Begin End;
delimiter //
create procedure math_demo()begin
declare i int default 0;
declare d decimal(10,4)default 0;
declare f float default 0;
while i < 10000 do
set d = d +.0001;
set f = f +.0001E0;
set i = i + 1;
end while;
select d,f;end // call math_demo();
mysql中的自定義方法的使用 delimiter // create function function_name()returns return_type;begin
end;// 執(zhí)行mysql自定義的函數(shù)用 Select function_name();
#mysql中的存儲(chǔ)過程 delimiter //
create procedure math_demo()begin
declare i int default 0;
declare d decimal(10,4)default 0;…….return return_value;
declare f float default 0;
while i < 10000 do
set d = d +.0001;
set f = f +.0001E0;
set i = i + 1;
end while;
select d,f;end // call math_demo();// delimiter // create function xiaoxiao()returns int begin return 2;end;// #在mysql中創(chuàng)建的自定義函數(shù)要加的delimiter,都要一次性選中執(zhí)行。每條語句都要用分號(hào)結(jié)束。delimiter // create function xiaoxiao1()returns int begin return 2;end // #執(zhí)行mysql中的自定義函數(shù) select xiaoxiao1();
根據(jù)一個(gè)布爾值來檢驗(yàn)一個(gè)值,在這里布爾值可以是true,false,unknown;
運(yùn)算符: 等號(hào):=,<=>,不等號(hào):!=,<>;賦值號(hào)::=;? XOR
邏輯XOR。當(dāng)任意一個(gè)操作數(shù)為 NULL時(shí),返回值為NULL。對(duì)于非 NULL 的操作數(shù),假如一個(gè)奇數(shù)操作數(shù)為非零值,則計(jì)算所得結(jié)果為 1,否則為 0。
a XOR b 的計(jì)算等同于(a AND(NOT b))OR((NOT a)和 b)。
Coalesce();函數(shù)的使用方法:
返回值為列表中第一非null值,在沒有非null值的情況下返回null。
Greatest();函數(shù)的使用及功能說明:
當(dāng)函數(shù)有2個(gè)或者2個(gè)以上的參數(shù)時(shí),返回參數(shù)中的最大參數(shù)值,比較參數(shù)所依據(jù)的規(guī)律同least()函數(shù)相同。
Interval();函數(shù)的使用及功能說明: INTERVAL(N,N1,N2,N3,...)
假如N < N1,則返回值為0;假如N < N2 等等,則返回值為1;假如N 為NULL,則返回值為-1。所有的參數(shù)均按照整數(shù)處理。為了這個(gè)函數(shù)的正確運(yùn)行,必須滿足 N1 < N2 < N3 < ……< Nn。其原因是使用了二分查找(極快速)。
Least();函數(shù)的使用及功能說明: · LEAST(value1,value2,...)
在有兩個(gè)或多個(gè)參數(shù)的情況下,返回值為最小(最小值)參數(shù)。用一下規(guī)則將自變量進(jìn)行對(duì)比:
o 假如返回值被用在一個(gè) INTEGER 語境中,或是所有參數(shù)均為整數(shù)值,則將其作為整數(shù)值進(jìn)行比較。
假如返回值被用在一個(gè) REAL語境中,或所有參數(shù)均為實(shí)值,則 將其作為實(shí)值進(jìn)行比較。
o 假如任意一個(gè)參數(shù)是一個(gè)區(qū)分大小寫的字符串,則將參數(shù)按照區(qū)分大小寫的字符串進(jìn)行比較。
o 在其它情況下,將參數(shù)作為區(qū)分大小寫的字符串進(jìn)行比較。o
假如任意一個(gè)自變量為NULL,則 LEAST()的返回值為NULL。
二,控制流函數(shù) Case的使用: 格式1: Case value
when [compare_value] then result_value when [compare_value2] then result_value2 else result_value3 end
格式2: case when value=[compare_value1] then result_value else result_value2 end
? IF(expr1,expr2,expr3)
如果 expr1 是TRUE(expr1 <> 0 and expr1 <> NULL),則 IF()的返回值為expr2;否則返回值則為 expr3。IF()的返回值為數(shù)字值或字符串值,具體情況視其所在語境而定。
ASCII()函數(shù)查看對(duì)應(yīng)符號(hào)的ascii碼。
第三篇:MySql知識(shí)點(diǎn)總結(jié)
1.數(shù)據(jù)庫創(chuàng)建 : Create database db_name;
數(shù)據(jù)庫刪除 : Drop database db_name;刪除時(shí)可先判斷是否存在,寫成 : drop database if exits db_name.建表 : 創(chuàng)建數(shù)據(jù)表的語法 : create table table_name(字段1 數(shù)據(jù)類型 , 字段2 數(shù)據(jù)類型);
例 : create table mytable(id int , username char(20));
刪表 : drop table table_name;例 : drop table mytable;.添加數(shù)據(jù) : Insert into 表名 [(字段1 , 字段2 , ….)] values(值1 , 值2 , …..);
如果向表中的每個(gè)字段都插入一個(gè)值,那么前面 [ ] 括號(hào)內(nèi)字段名可寫也可不寫
例 : insert into mytable(id,username)values(1,’zhangsan’);.查詢 : 查詢所有數(shù)據(jù) : select * from table_name;
查詢指定字段的數(shù)據(jù) : select 字段1 , 字段2 from table_name;
例 : select id,username from mytable where id=1 order by desc;多表查詢語句------------參照第17條實(shí)例.更新指定數(shù)據(jù) , 更新某一個(gè)字段的數(shù)據(jù)(注意,不是更新字段的名字)
Update table_name set 字段名=’新值’ [, 字段2 =’新值’ , …..][where id=id_num] [order by 字段 順序]
例 : update mytable set username=’lisi’ where id=1;
Order語句是查詢的順序 , 如 : order by id desc(或asc), 順序有兩種 : desc倒序(100—1,即從最新數(shù)據(jù)往后查詢),asc(從1-100),Where和order語句也可用于查詢select 與刪除delete.刪除表中的信息 :
刪除整個(gè)表中的信息 : delete from table_name;
刪除表中指定條件的語句 : delete from table_name where 條件語句;條件語句如 : id=3;.創(chuàng)建數(shù)據(jù)庫用戶
一次可以創(chuàng)建多個(gè)數(shù)據(jù)庫用戶如:
CREATE USER username1 identified BY ‘password’ , username2 IDENTIFIED BY ‘password’…..用戶的權(quán)限控制:grant
庫,表級(jí)的權(quán)限控制 : 將某個(gè)庫中的某個(gè)表的控制權(quán)賦予某個(gè)用戶
Grant all ON db_name.table_name TO user_name [ indentified by ‘password’ ];.表結(jié)構(gòu)的修改
(1)增加一個(gè)字段格式:
alter table table_name add column(字段名 字段類型);----此方法帶括號(hào)
(2)指定字段插入的位置:
alter table table_name add column 字段名 字段類型 after 某字段;
刪除一個(gè)字段:
alter table table_name drop字段名;
(3)修改字段名稱/類型
alter table table_name change 舊字段名 新字段名 新字段的類型;
(4)改表的名字
alter table table_name rename to new_table_name;
(5)一次性清空表中的所有數(shù)據(jù)
truncate table table_name;此方法也會(huì)使表中的取號(hào)器(ID)從1開始.增加主鍵,外鍵,約束,索引。。(使用方法見17實(shí)例)
① 約束(主鍵Primary key、唯一性Unique、非空Not Null)
② 自動(dòng)增張 auto_increment
③外鍵Foreign key-----與reference table_name(col_name列名)配合使用,建表時(shí)單獨(dú)使用
④ 刪除多個(gè)表中有關(guān)聯(lián)的數(shù)據(jù)----設(shè)置foreign key 為set null---具體設(shè)置參考幫助文檔.查看數(shù)據(jù)庫當(dāng)前引擎
SHOW CREATE TABLE table_name;
修改數(shù)據(jù)庫引擎
ALTER TABLE table_name ENGINE=MyISAM | InnoDB;.SQL語句運(yùn)用實(shí)例:
--1 建users表
create table users
(id int primary key auto_increment, nikename varchar(20)not null unique, password varchar(100)not null, address varchar(200),reg_date timestamp not null default CURRENT_TIMESTAMP);
--2 建articles表,在建表時(shí)設(shè)置外鍵
create table articles(id int primary key auto_increment,content longtext not null,userid int,constraint foreign key(userid)references users(id)on delete set null);
---------
--2.1 建articles表,建表時(shí)不設(shè)置外鍵
create table articles(id int primary key auto_increment,content longtext not null,userid int);
--2.2 給articles表設(shè)置外鍵
alter table articles add constraint foreign key(userid)references users(id)on delete set null;
----------
--3.向users表中插入數(shù)據(jù),同時(shí)插入多條
insert into
users
(id,nikename,password,address)
values(1,'lyh1','1234',null),(10,'lyh22','4321','湖北武漢'),(null,'lyh333','5678', '北京海淀');
--4.向article中插入三條數(shù)據(jù)
insert
into
articles
(id,content,userid)
values(2,'hahahahahaha',11),(null,'xixixixixix',10),(13,'aiaiaiaiaiaiaiaiaiaiaiaia',1),(14,'hohoahaoaoooooooooo',10);
--5.進(jìn)行多表查詢,選擇users表中ID=10的用戶發(fā)布的所有留言及該用戶的所有信息
select articles.id,articles.content,users.* from users,articles where users.id=10 and articles.userid=users.id order by articles.id desc;
--6.查看數(shù)據(jù)庫引擎類型
show create table users;
--7.修改數(shù)據(jù)庫引擎類型
alter table users engine=MyISAM;---因?yàn)閡sers表中ID被設(shè)置成外鍵,執(zhí)行此句會(huì)出錯(cuò)
--8.同表查詢,已知一個(gè)條件的情況下.查詢ID號(hào)大于用戶lyh1的ID號(hào)的所有用戶
select a.id,a.nikename,a.address from users a,users b where b.nikename='lyh1' and a.id>b.id;
------也可寫成
select id,nikename,address from users where id>(select id from users where nikename='lyh1');
9.顯示年齡比領(lǐng)導(dǎo)還大的員工:
select a.name from users a,users b where a.managerid=b.id and a.age>b.age;
查詢編號(hào)為2的發(fā)帖人: 先查articles表,得到發(fā)帖人的編號(hào),再根據(jù)編號(hào)查users得到的用戶名。
接著用關(guān)聯(lián)查詢.select * from articles,users得到笛卡兒積,再加order by articles.id以便觀察
使用select * from articles,users where articles.id=2 篩選出2號(hào)帖子與每個(gè)用戶的組合記錄
再使用select * from articles,users where articles.id=2 and articles.userid=users.id選出users.id等于2號(hào)帖的發(fā)帖人id的記錄.只取用戶名:select user where user.id=(select userid from articles where article.id =2)
找出年齡比小王還大的人:假設(shè)小王是28歲,先想找出年齡大于28的人
select * from users where age>(select age from users where name='xiaowang');
*****要查詢的記錄需要參照表里面的其他記錄:
select a.name from users a,users b where b.name='xiaowang' and a.age>b.age
表里的每個(gè)用戶都想pk一下.select a.nickname,b.nickname from users a,users b where a.id>b.id;
更保險(xiǎn)的語句:select a.nickname,b.nickname from(select * from users order by id)a,(se
lect * from users order by id)b where a.id>b.id;
再查詢某個(gè)人發(fā)的所有帖子.select b.* from articles a , articles b where a.id=2 and a.userid=b.userid
說明: 表之間存在著關(guān)系,ER概念的解釋,用access中的示例數(shù)據(jù)庫演示表之間的關(guān)系.只有innodb引擎才支持foreign key,mysql的任何引擎目前都不支持check約束。
第四篇:mysql數(shù)據(jù)庫要點(diǎn)總結(jié)
查詢(R)Selec子句
書寫順序
Select distinct:要返回的列或表達(dá)式 From:從中檢索數(shù)據(jù)的表 Where:行級(jí)過濾/分組前過濾 group by:分組說明
having:組級(jí)過濾/分組后過濾 order by:輸出排序順序desc/asc limit start, count:要檢索的行數(shù) limit 3,4 從第3行開始的連續(xù)4行
SELECT order_num,sum(quantity*item_price)ordertotal FROM orderitems WHEREorder_numBETWEEN20005AND 20009GROUP BY order_num HAVINGsum(quantity*item_price)>=50ORDER BYordertotalDESCLIMIT4;執(zhí)行順序
From表名->inner/left/right/ join on->where->group by->select distinct *->having->order by->limit start, count 插入Insert into(C)INSERT INTO students(name)values(‘楊過’),(‘小龍女’);更新(U)Update UPDATE customers SETcust_email = ‘elmer@fudd.com’WHEREcust_id = 10005;刪除(D)Delete DELETE FROM customers WHEREcust_id = 10006;Truncate刪除原來的表并重新創(chuàng)建一個(gè)表,刪除標(biāo)的全部?jī)?nèi)容時(shí)效率高。
操作表
創(chuàng)建CREATE TABLE customers(Cust_idint not null auto_increment primary key,Cust_name char(50)not null,Cust_addresschar(50)null)engine = innoDB;更新ALTER TABLE刪除DROP TABLEcustomers2;重命名RENAME TABLE customers2 TO customers;操作數(shù)據(jù)庫
創(chuàng)建CREATE DATABASE xxx charset = utf8;刪除DROP DATABASEXXX;切換USE XXX;查看SHOW DATABASES;關(guān)聯(lián)查詢
INNER/LEFT/RIGHTJOIN ON SELECT students.name,subjects.title,scores.scoreFROM scores INNER JOIN students ONscores.stuid = students.id INNER JOIN subjects ONscores.subid = subjects.id;
第五篇:MySQL學(xué)習(xí)心得
MySQL學(xué)習(xí)心得
第一章
一、數(shù)據(jù)庫管理系統(tǒng)(DBMS)是操作和管理數(shù)據(jù)庫的大型軟件,它按一定的數(shù)據(jù)模型組織數(shù)據(jù)。
例如:Oracle、SQL Server、MySQL、Access。
二、數(shù)據(jù)庫應(yīng)用系統(tǒng)在數(shù)據(jù)庫管理系統(tǒng)(DBMS)支持下建立的計(jì)算機(jī)應(yīng)用系統(tǒng),簡(jiǎn)寫:DBAS。
例如:.net Java。
三、字符集從大到小排序:utf8--gbk--gb2312。
四、mysql的特點(diǎn):
適用于中小型網(wǎng)站中,體積小、速度快、總體擁有成本低,尤其是有開放源碼這一特點(diǎn)。
五、目前Internet上滸的網(wǎng)站構(gòu)架方式是LAMP(Linux+apache+mysql+php)即使用Linux作為操作系統(tǒng),Apache作為Web服務(wù)器,MySQL作為數(shù)據(jù)庫,PHP作為服務(wù)器端腳本解釋器,由于4個(gè)軟件都是遵循GPL的開放源碼軟件,因此使用這種方式不用花一分錢就可以建立起一個(gè)穩(wěn)定、免費(fèi)的網(wǎng)站系統(tǒng)。
第二章
一、安裝過程中遇到的問題及解決方法:
安裝過程中沒有完成時(shí)計(jì)算機(jī)關(guān)機(jī)。(沒有刪除完文件)安裝完成時(shí)找不到所配置的路徑。(可以從配置文件中找到)
安裝完成后無法正常使用。(在計(jì)算機(jī)管理中重新啟動(dòng)MySQL服務(wù))安裝到一半時(shí)沒有出現(xiàn)下一步。(誤把配置文件刪除了)安裝到最后一步時(shí)start service錯(cuò)誤。到控制面板里面先把mysql刪除.到c盤C:Program Files目錄下把mysql目錄刪除.如果在其他盤還有設(shè)置目錄也要?jiǎng)h除.空目錄也要?jiǎng)h除 到regedit把注冊(cè)表
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Applications/MySQL HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services/Eventlog/Applications/MySQL HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Applications/MySQL 有的話,全部刪除!(技巧:用F3循環(huán)查找“mysql”)如果任務(wù)管理器里有關(guān)mysql內(nèi)容也刪除 把防火墻關(guān)了
重新裝mysql(這里我沒有重啟計(jì)算機(jī))
重裝時(shí)候有必要的話,重啟計(jì)算機(jī),停用IIS,和刪除temp里的臨時(shí)文件.實(shí)在不行的話,配置mysql時(shí)候,把mysql服務(wù)換個(gè)服務(wù)名.使用時(shí)輸入中文會(huì)出錯(cuò)。(在配置時(shí)在“Character Set”選框中將latinl修改為gb2312;也可以在配置文件中修改)
二、啟動(dòng)服務(wù)器的方法: ① 方法1:
在 “計(jì)算機(jī)管理”中的“服務(wù)”項(xiàng)目中啟動(dòng)與停止。② 方法2: 使用命令(net start mysql和net stop mysql)
三、連接MySQL 格式: mysql-h主機(jī)地址-u用戶名 -p用戶密碼
①先在打開DOS窗口,然后進(jìn)入目錄 mysqlbin(如果設(shè)置了環(huán)境變量,則直接輸入命令即可。)②鍵入命令mysql-uroot-proot ③接回車即可進(jìn)入到MYSQL中了 MYSQL的提示符是:mysql> 注明:直接打開Mysql command line client
四、MySQL注釋符有三種: ①#...②“--...” ③
五、忘記密碼重新更改密碼
先停止mysql服務(wù),修改D:MySQLMySQL Server 5.0 目錄下的my.ini文件,在[mysqld]下添加skip-grant-tables 啟動(dòng)mysql服務(wù)后就可以以空密碼登錄,之后別忘記修改root密碼
use mysql update user set password=password('hanaixia')where user='root';(分號(hào)不能少)password('hanaixia')此處必須用函數(shù)設(shè)置。
修改密碼后需要重新啟動(dòng)服務(wù)或者使用 flush privileges;語句,用于從mysql數(shù)據(jù)庫中的授權(quán)表重新載入權(quán)限。
把 skip-grant-tables 這一句刪掉再重啟mysql服務(wù)。