cmake編譯安裝MySQL5.5.32

1.安裝cmakemysql

上傳tar包sql

rz cmake-2.8.8.tar.gz

解壓tar包,並進入解壓後的文件夾數據庫

tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8

編譯和安裝bash

./configure
gmake && gmake install

2.安裝mysqlapp

上傳mysql-5.5.32.tar.gz加密

rz mysql-5.5.32.tar.gz

解壓mysql-5.5.32.tar.gzserver

tar xf mysql-5.5.32.tar.gz

進入到mysql-5.5.32blog

cd mysql-5.5.32

建立mysql用戶ip

useradd mysql -s /sbin/nologin -M

yum 安裝依賴庫ci

yum install ncurses-devel -y

指定cmake編譯參數

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0

編譯和安裝

make && make install 

添加環境變量到profile

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

source /etc/profile

echo $PATH

建立軟鏈接,連接mysql-5.5.32 到mysql

ln -s /application/mysql-5.5.32 /application/mysql

複製my-small.cnf配置文件到/etc/下並更名爲my.cnf

cp /tools/mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf

受權data tmp目錄的屬組和用戶

chown -R mysql.mysql /application/mysql/data/
chmod -R 1777 /tmp/

3.初始化數據庫

cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

複製啓動腳本到/etc/init.d/下並更名爲mysqld

cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld

給mysqld賦予可執行權限

chmod +x /etc/init.d/mysqld

啓動mysqld

/etc/init.d/mysqld start

檢查mysqld是否啓動起來

netstat -luptn |grep mysqld

給mysqld設置開機啓動

chkconfig mysqld on
chkconfig --list |grep mysqld

給數據庫添加密碼

/application/mysql/bin/mysqladmin -u root password 'admin'
相關文章
相關標籤/搜索