1、官網下載地址:
https://cdn.MySQL.com//Downloads/MySQL-5.7/mysql-boost-5.7.29.tar.gz
【此包中含boost】
2、創建安裝目錄
mkdir -p /usr/local/mysql
mkdir -p /data/mysql/data
3、創建用戶和組
groupadd mysql
useradd -g mysql mysql
4、授權
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mysql/data
5、安裝依賴包
yum -y install make gcc gcc-c++ cmake bison-devel ncurses ncurses-devel openssl-devel bison
6、cmake編譯
cmake
-DWITH_BOOST=boost/boost_1_59_0
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/data/mysql/data
-DSYSCONFDIR=/etc
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DMYSQL_TCP_PORT=3306
-DENABLED_LOCAL_INFILE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DWITH_SSL=system
7、make編譯
make
【lscpu
make -j [需要添加編譯的cpu數量,提高編譯速度] 】
8、vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
skip-name-resolve
#innodb_buffer_pool_size=2048M
max_connections=500
collation_server=utf8_bin
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
lower_case_table_names=0
key_buffer_size = 600M
max_allowed_packet = 100M
table_open_cache = 1024
sort_buffer_size = 6M
read_buffer_size = 6M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 64
query_cache_size = 256M
innodb_log_file_size = 1024M
innodb_log_files_in_group = 3
#log-error=/usr/local/mysql/log/mysqld.log
[client]
default-character-set = utf8
9、初始化
cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data/
10、環境變量設置
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
11、復制啟動文件:
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
12、啟動數據庫:
/etc/init.d/mysqld start
13、修改臨時密碼
alter user 'root'@'localhost' identified by 'ik0@110';
14、添加到開發服務
chkconfig --add /etc/init.d/mysqld
15、設置開機啟動
chkconfig mysqld on
99、MySQL忘記root密碼
解決方法:
1)在my.cnf中加上skip-grant-tables后 service mysqld restart
2)登錄后執行
update mysql.user set authentication_string=password(‘jew@110’) where user=‘root’;
flush privileges;
3)執行成功后將my.cnf 文件改回去,重啟MySQL,使用新密碼登錄,MySQL已安裝完成。
4)然后mysql就可以連接了,但此時操作似乎功能不完全,還要alter user…
mysql> alter user 'root'@'localhost' identified by 'qldassword(‘r31@110’) where user=‘root’;
flush privileges;
3)執行成功后將my.cnf 文件改回去,重啟MySQL,使用新密碼登錄,MySQL已安裝完成。
4)然后mysql就可以連接了,但此時操作似乎功能不完全,還要alter user…
mysql> alter user 'root'@'localhost' identified by 'qld@110';