一.創(chuàng)建用戶和路徑
1. 創(chuàng)建 MySQL 用戶組和用戶
# groupadd mysql
# useradd -g mysql mysql
2.創(chuàng)建數(shù)據(jù)存儲(chǔ)路徑
# mkdir /data/dbfile
# chown -R mysql.mysql /data/dbfile
二.安裝 mysql 5.x.x.tar.gz
1.編譯
默認(rèn)字符集
擴(kuò)展字符集
安裝Innodb
指定數(shù)據(jù)存儲(chǔ)路徑
指定系統(tǒng)配置文件路徑
# ./configure --prefix=/data/mysql5 --with-charset=utf8 --with-extra-charsets=all --with-plugins=partition,heap,innobase,myisam --enable-thread-safe-client --without-docs --with-pthread --enable-static --with-big-tables --without-debug --localstatedir=/data/dbfile --sysconfdir=/etc ----infodir=/data/mysql5
# make
# make install
2.拷貝 my.cnf
# cp mysql-5.1.31/support-files/my-medium.cnf /etc/my.cnf
3.初始化數(shù)據(jù)庫(kù)
# mysql5131/bin/mysql_install_db --user=mysql
4.啟動(dòng) MySQL 服務(wù)
# mysql5/bin/mysqld_safe --user=mysql &
5.停止 MySQL 服務(wù)
# mysql5/bin/mysqladmin shutdown
6.MySQL 調(diào)優(yōu) my.cnf
包含Innodb配置
7.刪除舊 Innodb 日志文件
# rm /data/dbfile/ibdata1 ib_logfile0 ib_logfile1
8.重啟 MySQL
9.查看 Innodb 運(yùn)行狀態(tài)
mysql > show variables like '%innodb%';
+---------------------------------+------------------------+
| Variable_name | Value |
+---------------------------------+------------------------+
| have_innodb | YES |
+---------------------------------+------------------------+
三.創(chuàng)建數(shù)據(jù)庫(kù)
mysql > GREATE DATABASE aa;
【查看 aa 默認(rèn)字符集】
mysql > show table status from test like '%aa%'G;
*************************** 1. row ***************************
Name: aa
Engine: InnoDB
Version: 10
Row_format: Fixed
Rows: 8
Avg_row_length: 7
Data_length: 56
Max_data_length: 1970324836974591
Index_length: 1024
Data_free: 0
Auto_increment: NULL
Create_time: 2009-04-13 10:28:14
Update_time: 2009-04-13 11:51:37
Check_time: NULL
Collation: gbk_chinese_ci
Checksum: NULL
Create_options:
Comment:
四.設(shè)置 MySQL 服務(wù)開機(jī)自啟動(dòng)
通過 service mysql start | stop | restart 管理 mysql 服務(wù)
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld 設(shè)置使mysql每次啟動(dòng)都能自動(dòng)運(yùn)行
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
# service mysqld start //啟動(dòng)mysqld服務(wù)
五.設(shè)置全局登錄
通過 # mysql 直接登錄
export PATH=$PATH:/data/mysql5/bin
[@more@]