LAMP、LNMP實戰之四搭建mysql(持續更新)
LAMP、LNMP實戰之四搭建mysql
說明:服務器192.168.2.32
數據庫版本mysql5.5.32
cmake版本2.8.8
yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* //安裝編譯環境gcc
yum install -y mysql-devel //安裝msyqlku
yum install lrzsz -y //安裝上傳、下載工具
mkdir /home/www/tools -p //在32上創建目錄
cd /home/www/tools/ //進入目錄
rz上傳cmake-2.8.8.tar.gz和mysql-5.5.32.tar.gz
tar xf cmake-2.8.8.tar.gz //解壓make
cd cmake-2.8.8 //進入cmake目錄
./configure && gmake && gmake install //編譯cmake
cd .. //退出cmake目錄
useradd mysql -s /sbin/nologin -M //創建用戶屬於mysql組
tar xf mysql-5.5.32.tar.gz //解壓mysql
cd mysql-5.5.32 //進入mysql目錄
輸入以下內容並回車
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 \
-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 //安裝mysql
ln -s /application/mysql-5.5.32/ /application/mysql //創建軟連接
cd .. //退出mysql目錄
cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
按y
echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile //編輯環境變量
source /etc/profile //即時生效
chown -R mysql.mysql /application/mysql/data/ //用戶賦權
chmod -R 1777 /tmp/ //文件夾賦權
cd /application/mysql/scripts/ //進入初始化目錄
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql //初始化mysql
cd /home/www/tools/mysql-5.5.32 //進入目錄
cp support-files/mysql.server /etc/init.d/mysqld //創建開機自啟動文件
chmod +x /etc/init.d/mysqld //文件夾賦權
/etc/init.d/mysqld start //啟動mysql服務
/application/mysql//bin/mysqladmin -u root password ‘oldboy123‘ //添加密碼
mysql -uroot -poldboy123 //進入mysql
select user,host from mysql.user; //查看是否有空用戶
grant all privileges on test.* to [email protected]
quit //退出mysql
chkconfig mysqld on //設置開機啟動
LAMP、LNMP實戰之四搭建mysql(持續更新)