首頁  >  文章  >  資料庫  >  Mysql5.7.19在Centos7下安裝教學詳解

Mysql5.7.19在Centos7下安裝教學詳解

黄舟
黄舟原創
2017-09-14 11:32:261190瀏覽

這篇文章主要介紹了Centos7 下Mysql5.7.19安裝教程詳解,小編認為非常不錯,特此分享到腳本之家平台,需要的朋友參考下吧

1.下載

從官網下載mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz,版本為5.7.19

#下載位址:

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gzLinux

2、建立mysql使用者群組及使用者

#l  建立mysql使用者群組


#
#groupadd mysql

l  在mysql用戶群組下建立mysql用戶


#
#useradd mysql -g mysql

3、確定安裝目錄和資料目錄

#我的mysql安裝目錄為/data/mysql,資料目錄為/data/mysql/data。

4、上傳安裝檔到伺服器

mysql-5.7.19-linux-glibc2.12-x86_64.tar .gz檔透過ftp工具放到/data/installfiles目錄.

#5、解壓縮tar.gz檔/data目錄


#cd /data/installfiles
#tar -xvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

6、修改目錄名稱

將mysql-5.7.19-linux-glibc2.12-x86_64更名為mysql並移到/usr/local/ mysql下。


#mv mysql-5.7.19-linux-glibc2.12-x86_64 /data/mysql

7、建立存放資料目錄

在/data /mysql下建立data目錄


#mkdir /data/mysql/data

8、授權mysql用戶

 將mysql目錄及下面的檔案、子目錄檔案主改成mysql


#cd /data
#chown -R mysql:mysql mysql/

給與mysql目錄及下面的檔案、子目錄755權限


#chmod -R 755 mysql/

9.編譯安裝並初始化mysql,記住臨時密碼


#/data/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/data/mysql

當時安裝的暫存密碼為:root@localhost:3?2YBeSg:Nte 

10、建立日誌檔案目錄


#
mkdir -p /data/mysql/log/mariadb/
cd /data/mysql/log/mariadb/
touch mariadb.log
chmod -R 775 mariadb.log
chown -R mysql:mysql mariadb.log
chown -R mysql:mysql /data/mysql

11、啟動mysql服務


/data/mysql/support-files/mysql.server start

12、登入msyql,輸入密碼(密碼為第9步驟的初始化密碼)


#
#mysql -u root -p

13、 修改密碼為「123456」


msql>alter user 'root'@'localhost' identified by '123456';
mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;
mysql>quit

14、修改/etc/my.cnf檔案


#
# instructions in http://fedoraproject.org/wiki/Systemd
socket=/tmp/mysql.sock
[mysqld]
datadir=/data/mysql/data
socket=/tmp/mysql.sock
max_connections=1000
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/data/mysql/log/mariadb/mariadb.log
pid-file=/data/mysql/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

修改標紅部分內容。

總結

#

以上是Mysql5.7.19在Centos7下安裝教學詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn