人妻无码中文字幕永久在线,99RE6这里有精品热视频,国产成人综合色就色综合 ,蜜臀av在线观看

新聞建站cms系統(tǒng)、政府cms系統(tǒng)定制開發(fā)

廣州網(wǎng)站建設(shè)公司-閱速公司

asp.net新聞發(fā)布系統(tǒng)、報紙數(shù)字報系統(tǒng)方案
/
http://www.jdki.com.cn/
廣州網(wǎng)站建設(shè)公司
您當(dāng)前位置:首頁>網(wǎng)站技術(shù)

網(wǎng)站技術(shù)

MYSQl記錄過程中的使用經(jīng)驗

發(fā)布時間:2009/4/2 20:21:20  作者:  閱讀:716  

廣告:

記錄過程中的使用經(jīng)驗,不斷完善中...

1. 下載Windows版本的mysql,比如mysql-4.0.20d-win,運(yùn)行Setup程序,直接選擇安裝到c:\mysql目錄,否則還要配置my.ini或my.cnf。
2. 將c:\mysql\bin加入到系統(tǒng)環(huán)境變量"PATH"中。
3. 以服務(wù)形式運(yùn)行mysqld: mysqld --install 或者 net start mysql ,然后在"控制面板/管理工具/服務(wù)"中啟動mysql服務(wù)。
4. 命令行中運(yùn)行mysqlshow; mysql test 來測試是否安裝成功

######## 修改密碼

mysql> set password = password("new password");

######## 忘記了管理員密碼,如何改密碼

首先以ROOT身份進(jìn)入LINUX。

然后

1. 停止MySQL

[root@it jash]# /etc/rc.d/init.d/mysql stop

或者也可以終止MySQL進(jìn)程方式來

ps ax | grep MySQL
kill 進(jìn)程號

2. 繞過授權(quán)表,重啟MySQL
[root@it jash]# /usr/bin/safe_mysqld --skip-grant-tables &

3. 重設(shè)口令
[root@it jash]# mysqladmin -u root flush-privileges password "123456"


######## 登錄MySQL

mysql -h hostname -u username -p[password]

或者:

mysql -h hostname -u username --password=password

其中,hostname為裝有MySQL數(shù)據(jù)庫的服務(wù)器名稱,username和password分別是用戶的登錄名稱和口令。


######## 增加新用戶或修改已有用戶權(quán)限

mysql> grant select,insert,update,delete,index,alter,create,drop,references on
dbname.tablename to username@localhost identified by "passwd";

mysql> flush privileges;


######## 創(chuàng)建數(shù)據(jù)庫

以管理員身份登錄, 然后輸入:
mysql> create database dbname;


######## 切換數(shù)據(jù)庫

use dbname;


######## 創(chuàng)建表

create table userinfo( id int unsigned auto_increment not null, name varchar(15), phone bigint , primary key(id), key person(name,phone));

######## 查看有哪些數(shù)據(jù)庫和表

show databases;
show tables;


######## 查看表都有那些字段(field)

describe tablename;


######## 插入記錄(insert)

insert into tablename values("yahai", 3527, NULL);
insert into tablename values("malin", 3528, NULL);
insert into tablename values("guodong", 3529, NULL);

insert into userinfo (name, phone) values("yuanming", 3530);


######## 查詢記錄(select)

select * from userinfo where name = "malin";

復(fù)雜些的,從兩個表中查詢:

select * from db1.tb1 t1, db2.tb2 t2 where t1.id =1 and t2.id = 1;
select * from db1.tb1 t1, db1.tb2 t2 where t1.id =1 and t2.id = 1;

######## 修改記錄(update)

update userinfo set name = 'malin', phone=3529, id = 4 where name = "malin1";


######## 刪除記錄(delete)

delete from userinfo where id = 3;


######## 復(fù)制表(select as)

create table userinfo1 as (select * from userinfo);


######## 刪除表(drop table)

drop table userinfo1;


######## 備份表

1.備份
mysqldump --add-drop-table --add-locks -u root -p dbname userinfo > a.txt

2.恢復(fù)
mysql -u root -p dbname < a.txt;


######## 將MySQL的操作結(jié)果從屏幕重新定向到文件

方法1:

創(chuàng)建腳本文件test.sh,內(nèi)容如下:

mysql -u username -p passwd -t dbname << 0
select * from tablename;

在shell中輸入:
test.sh >> a.txt;

方法2:

編輯一個腳本文件batch-file,內(nèi)容如下:

select * from tablename;

在shell中輸入:
mysql -u username -p passwd -t dbname < batch-file >> a.txt;

廣告:

相關(guān)文章
MYSQl
cms新聞系統(tǒng)購買咨詢
掃描關(guān)注 廣州閱速軟件科技有限公司
掃描關(guān)注 廣州閱速科技