下載rpm安裝包
Mysql官網(wǎng):https://dev.mysql.com/downloads/mysql/
選擇版本下載:
可以使用wget命令下載:
[root@localhost opt]#wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar
注意RedHat的版本和系統(tǒng)位數(shù)。
查看依賴的庫
[root@localhost opt]# yum search libaio [root@localhost opt]# yum install libaio
查看系統(tǒng)之前是否有安裝過mysql相關(guān)版本
[root@localhost opt]# rpm -qa | grep mysql [root@localhost opt]# rpm -qa | grep mariadb
有則刪除,有幾個刪除幾個
[root@localhost opt]# rpm -e mariadb-libs-5.5.44-2.el7.x86_64 --nodeps
安裝
按照順序安裝軟件包
[root@localhost opt]# rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm [root@localhost opt]# rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm [root@localhost opt]# rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm [root@localhost opt]# rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm
創(chuàng)建mysql用戶和用戶組
[root@localhost /]# groupadd mysql [root@localhost /]# useradd -r -g mysql -s /bin/false mysql
創(chuàng)建mysql數(shù)據(jù)存放目錄
[root@localhost /]# mkdir -p /data/mysql [root@localhost /]# chown mysql.mysql /data/mysql [root@localhost /]# ll -d /data/mysql/ drwxr-xr-x. 2 mysql mysql 6 9月 17 17:37 /data/mysql/
修改/etc/my.cnf配置文件
[mysqld] init-connect='SET NAMES utf8mb4' default-storage-engine=INNODB character-set-server=utf8mb4 datadir=/data/mysql socket=/var/lib/mysql/mysql.sock assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid validate_password=off sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION lower_case_table_names=1 [mysql] default-character-set = utf8mb4 [client] default-character-set = utf8mb4
初始化mysql
[root@localhost /]# /usr/sbin/mysqld --initialize --user=mysql
查看初始化密碼
[root@localhost /]# grep "root@localhost" /var/log/mysqld.log
登錄mysql并修改密碼
mysql> set password = password('123456');
允許遠(yuǎn)程訪問(不推薦)
mysql> use mysql; mysql> select host,user,password from user; mysql> update user set password=password('xxxxxx') where user='root'; mysql> update user set host='%' where user='root' and host='localhost'; mysql> flush privileges;
總結(jié)
以上所述是小編給大家介紹的RedHat6.5/CentOS6.5安裝Mysql5.7.20的教程詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com