個人筆記,班門弄斧,有錯誤請指正,感謝網上的前輩。
第一部分
一、相關包的下載下傳
zlib(支援壓縮的工具) 官方http://www.zlib.net/
jpeg(支援jpg格式的圖檔) 官方ftp://ftp.uu.net/graphics/jpeg
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
libpng(支援png 格式的圖檔) 官方http://www.libpng.org
ftp://ftp.simplesystems.org/pub/ ... ibpng-1.2.34.tar.gz
freetype 官方http://www.freetype.org
http://download.savannah.gnu.org ... eetype-2.3.5.tar.gz
gd 官方http://www.libgd.org/
http://www.libgd.org/releases/gd-2.0.35.tar.gz
Curl庫 官方http://curl.haxx.se
http://curl.haxx.se/download/curl-7.18.1.tar.gz
libxml 官方ftp://xmlsoft.org/libxml2/
ftp://xmlsoft.org/libxml2/libxml2-2.6.32.tar.gz
libxslt 官方http://ftp.gnome.org/pub/GNOME/sources/libxslt/
http://ftp.gnome.org/pub/GNOME/s ... bxslt-1.1.22.tar.gz
mysql 官方http://www.mysql.cn/
http://download.mysql.cn/download_file/gz/5.0/mysql-5.0.22.tar.gz
apache 官方 http://www.apache.org
http://apache.mirror.phpchina.com/httpd/httpd-2.2.8.tar.gz
php 官方 http://www.php.net
http://cn.php.net/distributions/php-5.2.5.tar.bz2
phpmyadmin(MYSQL可視化制作) 官方http://www.phpmyadmin.net/
http://jaist.dl.sourceforge.net/ ... s-utf-8-only.tar.gz
ZendOptimizer(PHP加速) 官方www.zend.com
http://downloads.zend.com/optimi ... glibc21-i386.tar.gz
二、安裝Mysql
# tar zxf mysql-5.0.21.tar.gz
# cd mysql-5.0.21
#./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql/
(./configure \
--prefix=/opt/mysql \
--with-unix-socket-path=/opt/mysql/tmp/mysql.sock \
--localstatedir=/opt/mysql/database/mysql_data \
--enable-assembler \
--with-mysqld-ldflags=-all-static \
--with-mysqld-user=mysql
編譯選項說明:
--prefix=/opt/mysql:将所有檔案安裝到/opt/mysql目錄下
--with-unix-socket-path=/opt/mysql/tmp/mysql.sock: 指定MySQL的
Unix socket檔案存放的目錄。
--localstatedir=/opt/mysql/database/mysql_data指定mysql的日志存放位置和資料庫位置。
--enable-assembler:允許使用彙編模式(優化性能)
--with-mysqld-ldflags=-all-static:伺服器使用靜态庫(優化性能)
--with-mysqld-user=mysql:指定MySQL的運作使用者。
其它常用編譯選項說明:
--without-server:僅編譯安裝用戶端工具。
--with-client-ldflags=-all-static:用戶端使用靜态庫。
--with-charset=CHARSET:指定MySQL使用的預設字元集。CHARSET可以是:
big5、cp1251、cp1257、czech、danish、dec8、dos、euc_kr、gb2312、gbk、german1、hebrew、hp8、hungarian、koi8_ru、koi8_ukr、latin1、latin2、sjis、swe7、tis620、ujis、usa7或win1251ukr。如果不指定,預設使用latin1。
)
說明:
#prefix=/usr/local/mysql mysql安裝的目标目錄
#sysconfdir=/etc my.ini配置檔案的路徑
#localstatedir=/var/lib/mysql 資料庫存放的路徑
# make
# make install
# groupadd mysql
# useradd mysql -g mysql
# cp support-files/my-medium.cnf /etc/my.cnf
#(這個檔案夾是原來編譯的目錄下的)詢問你是否要覆寫時,輸入"y"
#/usr/local/mysql/bin/mysql_install_db --user=mysql
# cd /usr/local/mysql 然後設定權限
# chown -R root . #設定root能通路/usr/local/mysql
# chown -R mysql /var/lib/mysql #設定mysql使用者能夠通路/var/lib/mysql
# chgrp -R mysql /usr/local/mysql #設定mysql組能通路/usr/local/mysql
# /usr/local/mysql/bin/mysqld_safe --user=mysql & #安全啟動mysql
#如果這裡沒什麼問題的話,應該是可以了,安裝好了。
如果要使用本地的用戶端工具,并且不想每次都輸入完整路徑,就需要設定
PATH變量。
export PATH=$PATH:/opt/mysql/bin
設定mysql開機自啟動:
# cp /usr/local/src/mysql-5.0.22/support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 700 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on #設定開機啟動mysqld服務
三、———————————————————————————————————————
# /usr/local/mysql/bin/mysqladmin -u root password 123456 #修改資料庫root使用者密碼為123456
# mysql -u root -p
Enter password: #輸入你剛才設定mysql root的管理密碼
備份資料庫:
mysqldump這個指令用于備份mysql:mysqldump -u root -p 資料庫名 > 備份路徑
如: mysqldump -u root -p mysql > /root/cc.sql
輸入密碼
注意備份資料庫要以管理者身份
導入資料庫:
mysql -u root -p 資料庫名 < 資料庫檔案
修複、檢查和優化.ism字尾的資料庫檔案:
isamchk
用來修複.myi字尾的資料庫檔案:
myisamchk /var/lib/mysql/mysql/*.MYI 檢查msyql資料庫中所有的.MYI檔案
如果有問題用-r參數來修複
myisamchk -r /var/lib/mysql/mysql/*.MYI
顯示使用者選擇的資料庫和表:mysqlshow
mysqlshow -u root -p 資料庫名
mysql的一些常用指令:
1、顯示資料庫清單。
格式:show databases;
2、顯示庫中的資料表:
格式:use mysql;show tables;
3、建庫:
格式:create database 庫名;
4、顯示資料表的結構:
格式:describe/desc 表名;
5、建表:
格式:use 庫名;create table 表名 (字段設定清單);
mysql> use testdb;
mysql> create table user
-> (
-> userid int not null,
-> username varchar(20) not null,
-> password varchar(50) not null,
-> email varchar(50),
-> primary key (userid)
-> );
6、删庫和删表:
格式:drop database 庫名; drop table 表名;
7、删除表中記錄清空:
格式:delete from 表名 where 條件;
delete from dtgrp where dt_id>=551801;
delete from systerm where term_id>551801 and term_id<5518120;
8、查詢表中的記錄:
格式:select * from 表名 where 條件;
9、插入字段:
insert into dtgrp values ('6572002','1');
10、更新字段:
格式:update 表名 set 列名1=值,列名2=值,... where 條件;
update systerm set term_id="2008001" where term_type="M";
11、将檔案資料導入到資料庫中
注意:文本資料應符合的格式:字段資料之間用 tab 鍵隔開,null 值用 \n 來代替
資料傳入指令
load data local infile "檔案名" into table 表名;
load data local infile "c:\\data.txt" into table user;
資料傳出指令
select * from 表名 into outfile "檔案名";
mysql的導入 mysql -u root -p 密碼 庫名< 要導入的庫名.sql
mysql的導出 mysqldump -u root -p 密碼 庫名> 要儲存的庫名.sql
整個mysql資料庫的備份 mysqldump -u root -p 密碼 -A >all.sql
———————————————————————————————————————
(未完待續……)