標籤:mysql 資料庫 源碼安裝
Mysql資料庫採用源碼安裝
[[email protected] ~]# wget -c http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17.tar.gz[[email protected] ~]# tar -zxf mysql-5.7.17.tar.gz[[email protected] ~]# cd mysql-5.7.17[[email protected] mysql-5.7.17]# yum install cmake ncurses-devel -y[[email protected] mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ #指定套間字路徑-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 \ #設定字元集-DDEFAULT_COLLATION=utf8_general_ci \ #設定字元校正集-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost #指定Boost擴充源碼路徑
---------------------------------------------------------------
CMake Warning:
Manually-specified variables were not used by the project:
WITH_MEMORY_STORAGE_ENGINE
WITH_READLINE
-- Build files have been written to: /root/mysql-5.7.17
---------------------------------------------------------------
出現上面的結果表示先行編譯成功!
[[email protected] mysql-5.7.17]# make -j grep ‘processor‘ /proc/cpuinfo | wc -l [[email protected] mysql-5.7.17]# make -j grep ‘processor‘ /proc/cpuinfo | wc -l install
檢查系統是否已經有mysql使用者,如果沒有則建立
[[email protected] mysql-5.7.17]# cat /etc/passwd | grep mysql[[email protected] mysql-5.7.17]# cat /etc/group | grep mysql
建立mysql使用者(但是不能使用mysql帳號登陸系統)
[[email protected] mysql-5.7.17]# groupadd mysql[[email protected] mysql-5.7.17]# useradd -g mysql -s /sbin/nologin mysql
修改許可權
[[email protected] mysql-5.7.17]# chown -R mysql:mysql /usr/local/mysql
[[email protected] mysql-5.7.17]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf[[email protected] mysql-5.7.17]# vim /etc/my.cnf###################[mysqld]basedir=/usr/local/mysqldatadir=/usr/local/mysql/datasocket=/usr/local/mysql/mysql.sockuser=mysql#innodb_force_recovery=6# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0log-bin=mysql-binserver-id = 1auto_increment_offset=1auto_increment_increment=2# 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=/usr/local/mysql/mysqld.logpid-file=/usr/local/mysql/mysqld.pid## include all files from the config directory#!includedir /etc/my.cnf.d
[[email protected] mysql-5.7.17]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql-5.7.17]# vim /etc/init.d/mysqld#####添加安裝目錄及資料目錄basedir=/usr/local/mysqldatadir=/usr/local/mysql/data
[[email protected] mysql-5.7.17]# chkconfig --add mysqld[[email protected] mysql-5.7.17]# chkconfig --level 35 mysqld on
進入/etc/profile設定環境變數
[[email protected] mysql-5.7.17]# vim /etc/profileexport PATH=/usr/local/mysql/bin:$PATH #在末尾添加[[email protected] mysql-5.7.17]# source /etc/profile
進入安裝路徑,執行初始化配置指令碼,建立系統內建的資料庫和表
#mysql5.7之前版本初始化配置表命令:
#script/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/
#mysql5.7已經放棄使用了,而且也沒有script目錄,可以使用下面這個
#[[email protected] mysql-5.7.17]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/
產生的初始密碼位於:
方法一:
[[email protected] mysql-5.7.17]# grep ‘temporary password‘ /var/log/mysqld.log 2016-07-08T02:25:46.311098Z 1 [Note] A temporary password is generated for [email protected]: MtPqF0/oN5zo
即初始密碼為 MtPqF0/oN5zo (密碼是隨機產生的,每台機器產生的都不一樣哦)
方法二:
[[email protected] mysql-5.7.17]# cat /root/.mysql_secret# The random password set for the root userat Fri Jan 10 20:00:34 2014 (local time): aJqZsA2m
這裡的aJqZsA2m就是產生的root隨機密碼啦
接下來,啟動資料庫,重設root密碼
[[email protected] mysql-5.7.17]# /etc/init.d/mysqld start
[[email protected] mysql-5.7.17]# mysql -uroot -pEnter password: # 輸入剛剛的隨機密碼連結資料庫mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘新密碼‘;
本文出自 “MQ_douer” 部落格,請務必保留此出處http://douer.blog.51cto.com/6107588/1933366
mysql資料庫源碼安裝