到mysql官網(wǎng)下載mysql編譯好的二進制安裝包,在下載頁面Select Platform:選項選擇linux-generic,然后把頁面拉到底部,64位系統(tǒng)下載Linux - Generic (glibc 2.5) (x86, 64-bit),32位系統(tǒng)下載Linux - Generic (glibc 2.5) (x86, 32-bit)
解壓32位安裝包:
進入安裝包所在目錄,執(zhí)行命令:tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz
復(fù)制解壓后的mysql目錄到系統(tǒng)的本地軟件目錄:
執(zhí)行命令:cp?mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r
注意:目錄結(jié)尾不要加/
添加系統(tǒng)mysql組和mysql用戶:
執(zhí)行命令:groupadd mysql和useradd -r -g mysql mysql
安裝數(shù)據(jù)庫:
進入安裝mysql軟件目錄:執(zhí)行命令 cd /usr/local/mysql
修改當(dāng)前目錄擁有者為mysql用戶:執(zhí)行命令?chown -R mysql:mysql ./
安裝數(shù)據(jù)庫:執(zhí)行命令?./scripts/mysql_install_db --user=mysql
修改當(dāng)前目錄擁有者為root用戶:執(zhí)行命令?chown -R root:root ./
修改當(dāng)前data目錄擁有者為mysql用戶:執(zhí)行命令?chown -R mysql:mysql data
到此數(shù)據(jù)庫安裝完畢
啟動mysql服務(wù)和添加開機啟動mysql服務(wù):
添加開機啟動:執(zhí)行命令cp support-files/mysql.server /etc/init.d/mysql,把啟動腳本放到開機初始化目錄
啟動mysql服務(wù):執(zhí)行命令service mysql start
執(zhí)行命令:ps -ef|grep mysql 看到mysql服務(wù)說明啟動成功,如圖
修改mysql的root用戶密碼,root初始密碼為空的:
執(zhí)行命令:./bin/mysqladmin -u root password '密碼'
把mysql客戶端放到默認路徑:
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
注意:建議使用軟鏈過去,不要直接包文件復(fù)制,便于系統(tǒng)安裝多個版本的mysql