目前最新爲5.7.16,能夠直接下載mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz,html
這裏用的是5.7.12,未下載最新的,不過,安裝方式同樣。node
官網地址: http://www.mysql.com/downloads/mysql
點擊Mysql Community Server後進入以下頁面:linux
選擇對應位數版本點擊Download,目前官網已經更新到5.7.16,能夠直接下載最新版本安裝,5.7安裝方式同樣:sql
進入下載頁面點擊下載便可:vim
下載完後經過Xftp等方式上傳到linux系統習慣目錄下。centos
[root@centos7 src]# rpm -qa|grep mariadb mariadb-libs-5.5.60-1.el7_5.x86_64 [root@centos7 src]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
[root@centos7 src]# rm -rf /etc/my.cnf
[root@centos7 src]# rpm -qa | grep mysql
[root@centos7 src]# cat /etc/group | grep mysql [root@centos7 src]# cat /etc/passwd | grep mysql [root@centos7 src]# groupadd mysql [root@centos7 src]# useradd -g mysql mysql
#cd /opt/Service/mysql #pwd #chown -R mysql . #chgrp -R mysql .
# bin/mysqld --initialize --user=mysql --basedir=/opt/Service/mysql --datadir=/opt/Service/mysql/data
!!!!此處須要注意記錄生成的臨時密碼,如上文結尾處的:YLi>7ecpe;YP !!!!
bash
#cd /opt/Service/mysql/support-files
查看有沒有 my-default.cnf 文件!沒有建立一個!內容以下:socket
# 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] explicit_defaults_for_timestamp=true #須要修改mysql地址 basedir = /opt/Service_ZY/mysql #須要修改mysql日誌地址 datadir = /opt/Service_ZY/mysql/data port = 3306 #mysqld.sock生成地址(不用修改) socket = /tmp/mysqld.sock character-set-server=utf8 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION [mysql] # mysql默認編碼 default-character-set = utf8mb4 [client] # mysql客戶端默認編碼 default-character-set = utf8mb4 #mysqld.sock生成地址(不用修改) socket=/tmp/mysqld.sock
# cp my-default.cnf /etc/my.cnf # cp mysql.server /etc/init.d/mysqld
# vim /etc/init.d/mysqld
修改如下內容:tcp
運行如下命令時會出現問題: -bash: mysql: command not found
ln -s /opt/Service/mysql/bin/mysql /usr/bin
# /etc/init.d/mysqld start
mysql> set password=password('root');
mysql>grant all privileges on *.* to 'root'@'%' identified by '123456';
mysql>flush privileges;
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
# vim /etc/profile
添加以下路徑:
export PATH=/opt/Service/mysql/bin:$PATH
以下: