下載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ù)。
查看依賴的庫(kù)
[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
有則刪除,有幾個(gè)刪除幾個(gè)
[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的教程詳解,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
您可能感興趣的文章:- centos6.5中rpm包安裝mysql5.7初始化出錯(cuò)的解決方法
- centos6.4下mysql5.7.18安裝配置方法圖文教程
- 阿里云ECS centos6.8下安裝配置MySql5.7的教程
- Centos6.9安裝Mysql5.7.18步驟記錄
- CentOS6.8使用cmake安裝MySQL5.7.18
- CentOS6.5下安裝Mysql5.7.18的教程詳解
- CentOS6.5 上部署 MySQL5.7.17 二進(jìn)制安裝以及多實(shí)例配置
- CentOS 6.2 安裝 MySQL 5.7.28的教程(mysql 筆記)