用戶名:mysql
安裝目錄:/usr/local/mysql
數(shù)據(jù)庫目錄:/data/mysql/data
源碼包:mysql-5.5.28.tar.gz
二、安裝準(zhǔn)備
添加用戶
useradd -s /sbin/nologin mysql
建立所需目錄
mkdir -p /data/mysql/data
chown -R mysql:mysql /data/mysql
安裝編譯所需文件或程序
yum install gcc gcc-c++ cmake ncurses-devel bison
下載源碼包
http://sourceforge.net/projects/mysql.mirror/files/MySQL%205.5.28/
wget http://ncu.dl.sourceforge.net/project/mysql.mirror/MySQL%205.5.28/mysql-5.5.28.tar.gz
三、編譯安裝
tar xzvf mysql-5.5.28.tar.gz
cd mysql-5.5.28
cmake -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DINSTALL_DATADIR=/data/mysql/data -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
參數(shù)說明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安裝目錄
-DMYSQL_DATADIR=/usr/local/mysql/data //數(shù)據(jù)庫存放目錄
-DWITH_MYISAM_STORAGE_ENGINE=1 //安裝myisam存儲引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 //安裝innodb存儲引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 //安裝archive存儲引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 //安裝blackhole存儲引擎
-DENABLED_LOCAL_INFILE=1 //允許從本地導(dǎo)入數(shù)據(jù)
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校驗字符
-DEXTRA_CHARSETS=all //安裝所有擴展字符集
-DMYSQL_TCP_PORT=3306 //MySQL監(jiān)聽端口
-DMYSQL_USER=mysql //MySQL用戶名
其他參數(shù):
-DWITH-EMBEDDED_SERVER=1 //編譯成embedded MySQL library (libmysqld.a)
-DSYSCONFDIR=/etc //MySQL配輯文件
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock //Unix socket 文件路徑
-DWITH_READLINE=1 //快捷鍵功能
-DWITH_SSL=yes //SSL
-DWITH_MEMORY_STORAGE_ENGINE=1 //安裝memory存儲引擎
-DWITH_FEDERATED_STORAGE_ENGINE=1 //安裝frderated存儲引擎
-DWITH_PARTITION_STORAGE_ENGINE=1 //安裝數(shù)據(jù)庫分區(qū)
-DINSTALL_PLUGINDIR=/usr/local/mysql/plugin //插件文件及配置路徑
make && make install
chown -R mysql:mysql /usr/local/mysql5.5/
mv /root/mysql-5.5.28/support-files/my-large.cnf /etc/my.cnf
mv /root/mysql-5.5.28/support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
開啟啟動
chkconfig --level 345 mysqld on
設(shè)置環(huán)境變量
echo "export PATH=/usr/local/mysql5.5/bin/:$PATH" >> /etc/profile
source /etc/profile
/usr/local/mysql5.5/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql5.5 --datadir=/data/mysql/data
vim /etc/my.cnf
basedir=/usr/local/mysql5.5
datadir=/data/mysql/data
創(chuàng)建mysql管理員
/usr/bin/mysqladmin -u root password 'z'
連接數(shù)據(jù)庫:
mysql -u root -p -P port
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com