檢查系統版本

[[email protected] etc]# echo $HOSTNAME
34b8e2970863
[[email protected] etc]# uname -a
Linux 34b8e2970863 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] etc]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

下載需要的元件

yum -y install wget  cmake gcc gcc-c++ ncurses  ncurses-devel  libaio-devel  openssl openssl-devel

下載mysql8.0.11含boost版

cd /opt/
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.11.tar.gz

編譯安裝

cd /opt/mysql-8.0.11
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql-8.0.11 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_DATADIR=/var/lib/mysql/ -DWITH_DEBUG=0 -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_ZLIB=system -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=./boost/
make && make install

建立mysql使用者及程式資料夾

ln -s /opt/mysql-8.0.11/ /usr/local/mysql
useradd mysql
chown -R mysql:mysql /usr/local/mysql
 mkdir /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
chmod 755 /usr/local/mysql -R
chmod 755 /var/lib/mysql -R

設定mysql設定檔

[[email protected] mysql]# cat /etc/my.cnf
[mysqld]
server-id=1
port=3306
basedir=/usr/local/mysql
datadir=/var/lib/mysql
skip-name-resolve

mysql初始化

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/var/lib/mysql
/usr/local/mysql/bin/mysql_ssl_rsa_setup

建立軟聯接

ln -s /usr/local/mysql/bin/* /usr/local/bin/

啟動mysql

/usr/local/mysql/bin/mysqld_safe --user=mysql &

修改帳號密碼

/usr/local/mysql/bin/mysql -uroot -p 
mysql> alter user 'root'@'localhost' identified by "123456";
mysql> flush privileges;

新增帳號

CREATE USER `tony`@`%` IDENTIFIED BY '123456';  
GRANT ALL ON *.* TO `tony`@`%` WITH GRANT OPTION;
ALTER USER 'tony'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

更新帳號

ALTER USER 'root'@'127.0.0.1' IDENTIFIED BY 'passowrd' PASSWORD EXPIRE NEVER; #修改加密規則為永不過期 
ALTER USER 'root'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下使用者的密碼加密方式為之前版本的方式 
FLUSH PRIVILEGES; #重新整理許可權 

測試登入正常

點閱: 264

By tony

自由軟體愛好者~喜歡不斷的思考各種問題,有新的事物都會想去學習嘗試 做實驗並熱衷研究 沒有所謂頂天的技術 只有謙虛及不斷的學習 精進專業,本站主要以分享系統及網路相關知識、資源而建立。 Github http://stnet253.github.io

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料