您好,登錄后才能下訂單哦!
本篇內容主要講解“CentOS7.4環境下怎么用源碼安裝Mysql 5.7.26”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“CentOS7.4環境下怎么用源碼安裝Mysql 5.7.26”吧!
yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake make
mkdir /software cd /software wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26.tar.gz
查看下載包:
[root@localhost software]# ls mysql-5.7.26.tar.gz
tar -zxvf mysql-5.7.26.tar.gz
進入解壓后的目錄,為了保持源碼干凈,新建子目錄 yunxiaochong,在子目錄下編譯
[root@localhost software]# ls mysql-5.7.26 mysql-5.7.26.tar.gz [root@localhost software]# cd mysql-5.7.26/ [root@localhost mysql-5.7.26]# mkdir yunxiaochong [root@localhost mysql-5.7.26]# cd yunxiaochong/
cmake配置:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_SSL=bundled \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/tmp
注:
如果編譯出現錯誤,請先刪除CMakeCache.txt后,再重新編譯:
rm -rf CMakeCache.txt
如果出現下面的提示就表示成功生成了編譯環境:
-- Configuring done
-- Generating done
編譯:
make -j 10
安裝:
make instal
1 2 |
|
mkdir -p /data/mysql/{3306,3307}/{data,log}
chown -R mysql:mysql /data/mysql/ chown -R mysql:mysql /usr/local/mysql/
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile source /etc/profile
3306
vim /data/mysql/3306/my3306.cnf
內容如下:
[mysqld] basedir=/usr/local/mysql datadir=/data/mysql/3306/data port=3306 socket=/data/mysql/3306/mysql3306.sock character-set-server=utf8 log-error=/data/mysql/3306/log/error3306.log pid-file=/data/mysql/3306/mysqld3306.pid
3307
vim /data/mysql/3307/my3307.cnf
內容如下:
[mysqld] basedir=/usr/local/mysql datadir=/data/mysql/3307/data port=3307 socket=/data/mysql/3307/mysql3307.sock character-set-server=utf8 log-error=/data/mysql/3307/log/error3307.log pid-file=/data/mysql/3307/mysqld3307.pid
(1) 3306
1 |
|
(2) 3307
1 |
|
( 1) 3306
cd /usr/local/mysql/bin ./mysqld_safe --defaults-file=/data/mysql/3306/my3306.cnf --user=mysql &
(2)3307
cd /usr/local/mysql/bin ./mysqld_safe --defaults-file=/data/mysql/3307/my3307.cnf --user=mysql &
[root@localhost bin]# less /data/mysql/3307/log/error3307.log|grep 'A temporary password'
2019-07-22T02:04:41.482707Z 1 [Note] A temporary password is generated for root@localhost: Kjipuugr0:0v
登錄報錯:
[mysql@localhost ~]$ mysql -uroot -P3306 -S /data/mysql/3307/mysql3307.sock -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
解決方法:
(1)先關閉數據庫實例,由于不能登錄,所以只能有kill -9 執行殺掉進程。
(2)再配置文件中,添加選項
skip-grant-tables
(3)重啟數據庫實例
(4)免密碼登錄:
mysql -uroot -P3306 -S /data/mysql/3306/mysql3306.sock
(5.1)修改密碼過期策略:
MySQL [none]>use mysql MySQL [mysql]> update user set password_expired='N' where user='root'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
(5.2)修改密碼:
MySQL [none]>use mysql MySQL [mysql]> update user set authentication_string = password("Yxc@3306") where user="root" ; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
(6)重啟數據庫實例
[mysql@localhost ~]$ mysqladmin -uroot -S /data/mysql/3306/mysql3306.sock shutdown cd /usr/local/mysql/bin
./mysqld_safe --defaults-file=/data/mysql/3306/my3306.cnf --user=mysql &
MySQL [(none)]> create USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Yxc3307'; Query OK, 0 rows affected (0.00 sec) MySQL [(none)]> grant all privileges on *.* to 'root'@'%'; Query OK, 0 rows affected (0.00 sec)
說明:
MySQL8.0之前的版本密碼加密規則:mysql_native_password,
MySQL8.0密碼加密規則:caching_sha2_password
到此,相信大家對“CentOS7.4環境下怎么用源碼安裝Mysql 5.7.26”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。