1. 程式人生 > >Linux下mysql-5.7.20安裝

Linux下mysql-5.7.20安裝

版本 symbol 問題 init temporary rar files sans AS

1 參考文檔

https://dev.mysql.com/doc/refman/5.7/en/source-installation.html

https://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html

https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html

2 安裝

2.1 打開防火墻3306端口

$ sudo /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
$ sudo service iptables save

2.2 創建mysql用戶

$ groupadd mysql
$ useradd -r -g mysql -s /bin/false mysql

2.2 下載mysql和boost庫(對應版本高於或低於這個版本都有問題) https://dev.mysql.com/doc/refman/5.7/en/source-installation.html

$ wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
$ wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.20.tar.gz

安裝

$ tar zxvf  boost_1_59_0.tar.gz
$ mv boost_1_59_0 /usr/local/boost

$ tar zxvf mysql-5.7.20.tar.gz && cd mysql-5.7.20/ && mkdir bld && cd bld/
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=OFF -DWITH_BOOST=/usr/local/boost -DMYSQL_TCP_PORT=3306
.. $ make && make install $ mkdir /opt/mysql && mkdir /opt/mysql/data && mkdir /opt/mysql/log && touch /opt/mysql/log/mariadb.log $ chown -R mysql:mysql /opt/mysql

配置文件調整

$ vi /etc/my.cnf

[mysqld]
datadir=/opt/mysql/data
socket=/tmp/mysql.sock
# 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
# 忽略大小寫配置
lower_case_table_names=1
log-bin=mysql-bin
binlog-format=ROW
server-id=1

[mysqld_safe]
log-error=/opt/mysql/log/mariadb.log
pid-file=/tmp/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

初始化mysql 系統數據表

$ /usr/local/mysql/bin/mysqld --initialize --user=mysql

*************************************************************************************

[Note] A temporary password is generated for root@localhost: a5goRy5Yez/t

獲取臨時密碼:a5goRy5Yez/t

*************************************************************************************

啟動

$ /usr/local/mysql/bin/mysqld_safe --user=mysql &

開啟SSL

$ /usr/local/mysql/bin/mysql_ssl_rsa_setup

登錄 MySQL

$ /usr/local/mysql/bin/mysql -u root -p

# 修改root初始密碼
mysql> ALTER USER root@localhost identified by sloth@linux;

# 允許root外部訪問
mysql> use mysql
mysql> GRANT ALL ON *.* TO root@% IDENTIFIED BY sloth@linux;

配置自啟動

$ cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
$ chmod 755 /etc/init.d/mysql.server
$ chkconfig --add mysql.server
$ chkconfig --list

Linux下mysql-5.7.20安裝