Mysql-5.7.18安裝:
安裝依賴包:
# yum search libaio
# yum install libaio
建立使用者及組:
# groupadd mysql
# useradd mysql -g mysql
解壓:
# tar -axvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /r2/mysqldata
重命名:
# mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql
安裝:
# cd /r2/mysqldata
更改所有者:
# chown -R mysql.msyql mysql/
授權:
# chmod 755 mysql/
編譯安裝:
# cd msysql
# ./bin/mysqld --user=mysql --basedir=/r2/mysqldata --datadir=/r2/mysqldata/data --initialize
當編譯安裝完成時特别注意看下面的初始密碼。
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# vi /etc/init.d/mysqld
将下面相關路徑修改成自己部署的相對應的目錄
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIn5GcuYmNkVDZhlDZ4QWYmdTN2MGM1MGMlBDM1MTN1ATYkVDOfdWbp9CXt92Yu4GZjlGbh5SZslmZxl3Lc9CX6MHc0RHaiojIsJye.png)
配置/etc/my.cnf
# vim /etc/my.cnf
本人同步的是192.168.101.130伺服器配置檔案
配置環境變量:
# echo "export PATH=$PATH:/r2/mysqldata/bin" >> /etc/profile
# source /etc/profile
啟動mysql:
# /etc/init.d/mysqld start
注:
1.如果出現UPDATNG PID等錯誤,請仔細檢查配置檔案/etc/my.cnf的相關路徑設定是否錯誤和錯誤提示下相關路徑下是否有檔案。
2.若忘記了資料庫密碼可編輯/etc/my.cnf添加:skip-grant-tables
3.在跳過密碼後登入設定密碼:
> update mysql.user set authentication_string=password('新密碼') where user='root';
4.注釋掉配置檔案中跳過密碼,使用密碼登入MySQL,若要再次修改密碼
> set password = password('xxxxxxxx');
> flush privileges;
5.授權:> GRANT ALL PRIVILEGES ON *.* TO 'root'@'luomr' IDENTIFIED BY '123456' WITH GRANT OPTION;
-------------------------------------------------------------
作者:
羅穆瑞出處:
http://www.cnblogs.com/kazihuo/轉載請保留此段聲明,且在文章頁面明顯位置給出原文連結,謝謝!
------------------------------------------------------------------------------
如果覺得這篇文章對你有小小的幫助的話,記得在右下角點個“推薦”哦,部落客在此感謝!