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"color: #ff0000">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
修改標紅部分內容。
總結
以上所述是小編給大家介紹的Centos7 下Mysql5.7.19安裝教程詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對電腦玩物網站的支持!
Tags: mysql data 目錄 linux-glibc 安裝 文件
文章來源: