1系統約定
安裝文件下載目錄:/data/software
Mysql目錄安裝位置:/usr/local/mysql
數據庫保存位置:/data/mysql
日誌保存位置:/data/log/mysqlhtml
2下載mysql
在官網:http://dev.mysql.com/downloads/mysql/ 中,選擇如下版本的mysql下載:mysql
執行以下命名:
#mkdir /data/software
#cd /data/softwarelinux
--下載安裝包 sql
--建議:在windows上使用迅雷下載,速度很快(個人是1M/s),而後用工具(Xftp)上傳到 /data/software目錄下;
#wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gzshell
3解壓壓縮包到目標位置數據庫
#cd /data/softwarevim
--解壓壓縮包windows
#tar -xzvf /data/software/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gzbash
--移動並修改文件名socket
#mv /data/software/mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql
4建立數據倉庫目錄
--/data/mysql 數據倉庫目錄
# mkdir /data/mysql
#ls /data/
5新建mysql用戶、組及目錄
# ---新建一個msyql組
# useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql ---新建msyql用戶禁止登陸shell
6改變目錄屬有者
#cd /usr/local/mysql
#pwd
#chown -R mysql .
#chgrp -R mysql .
#chown -R mysql /data/mysql
7配置參數
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
此處須要注意記錄生成的臨時密碼,如上文結尾處的:YLi>7ecpe;YP
#bin/mysql_ssl_rsa_setup --datadir=/data/mysql
8修改系統配置文件
#cd /usr/local/mysql/support-files
# cp my-default.cnf /etc/my.cnf
# cp mysql.server /etc/init.d/mysql
# vim /etc/init.d/mysql
修改如下內容:
9啓動mysql
# /etc/init.d/mysql start
--登錄
# mysql -hlocalhost -uroot -p
--若是出現:-bash: mysql: command not found
--就執行: # ln -s /usr/local/mysql/bin/mysql /usr/bin --沒有出現就不用執行
--輸入第6步生成的臨時密碼
--修改密碼
mysql> set password=password('root');
--設置root帳戶的host地址(修改了才能夠遠程鏈接)
mysql>grant all privileges on *.* to 'root'@'%' identified by 'root';
mysql>flush privileges;
--查看錶
mysql> use mysql;
mysql> select host,user from user;
--這裏就能夠使用遠程鏈接測試了;
10添加系統路徑
# vim /etc/profile
添加:
export PATH=/usr/local/mysql/bin:$PATH
以下:
# source /etc/profile
11配置mysql自動啓動
# chmod 755 /etc/init.d/mysql
# chkconfig --add mysql
# chkconfig --level 345 mysql on
以上就是linux環境Mysql 5.7.13安裝教程,但願對你們的學習有所幫助。
補充:
--退出mysql命令窗口
#exit
--查看mysql狀態
#service mysql status
--中止mysql
#service mysql stop
--啓動mysql
#service mysql start
附my.cnf(這是一個配置mysql配置文件,暫時能夠不用管,如你想鑽研 你能夠百度或google 「mysql my.cnf 配置詳情」)
/etc/my.cnf# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL.[mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.innodb_buffer_pool_size = 10G# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.log_bincharacter-set-server=utf8collation-server=utf8_bininit-connect='SET NAMES utf8'# These are commonly set, remove the # and set as required.basedir = /usr/local/mysqldatadir = /export/mysql/varport = 3306server_id = 22206socket = /export/mysql/mysql.sockbinlog_format = statement# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.join_buffer_size = 128Msort_buffer_size = 2Mread_rnd_buffer_size = 2Mlog_bin_trust_function_creators = onsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLESlower_case_table_names=1