MySQL是一款廣受歡迎的開源關系型數據庫管理系統,具有高性能、高可靠性和豐富的功能。本文將介紹如何在Linux系統中通過源碼安裝MySQL 5.5。
1. 下載MySQL 5.5源碼包
wget https://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.62.tar.gz
2. 解壓縮源碼包
tar -zxvf mysql-5.5.62.tar.gz
3. 安裝必要的依賴庫
yum install -y cmake ncurses-devel libaio-devel
4. 創建MySQL用戶和用戶組
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
5. 編譯安裝MySQL
cd mysql-5.5.62
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
6. 配置MySQL
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
vim /etc/my.cnf
# 修改以下參數
# basedir=/usr/local/mysql
# datadir=/usr/local/mysql/data
# socket=/var/run/mysqld/mysql.sock
chmod +x /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
mkdir /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql
7. 啟動MySQL
/etc/init.d/mysql start
至此,MySQL 5.5源碼安裝完成。你可以通過以下命令查看MySQL版本和狀態:
/usr/local/mysql/bin/mysql -V
/usr/local/mysql/bin/mysqladmin -uroot -p version