在lnmp nginx環境下重新編譯安裝mysql可以讓我們更好地優化數據庫的性能。以下是步驟:
1. 卸載舊版本的mysql
service mysqld stop yum remove mysql mysql-server mysql-libs
2. 下載mysql源碼包
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22.tar.gz
3. 解壓源碼包并進行配置
tar -zxvf mysql-5.7.22.tar.gz cd mysql-5.7.22 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \ -DMYSQL_DATADIR=/usr/local/mysql/data/ \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_BOOST=/usr/local/boost
4. 編譯并安裝
make && make install
5. 配置路徑和權限
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql echo 'export PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile source /etc/profile chown -R mysql:mysql /usr/local/mysql/ cd /usr/local/mysql/ scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
6. 啟動mysql服務
/etc/init.d/mysql start
7. 重置root密碼
/usr/local/mysql/bin/mysql_secure_installation
通過以上步驟,我們就可以在lnmp nginx環境下成功重新編譯安裝mysql,并且重置了root密碼。