您好,登錄后才能下訂單哦!
本文主要給大家介紹CentOS6.9系統編譯安裝MySQL5.7.16教程,其所涉及的東西,從理論知識來獲悉,有很多書籍、文獻可供大家參考,從現實意義角度出發,億速云累計多年的實踐經驗可分享給大家。
CentOS6.9編譯安裝MySQL5.7.16
部署環境:
系統CentOS6.9,mysql5.7.16,boost庫
系統為2G內存
1、安裝依賴包,使用yum安裝cmake,6.9默認yum源自帶
yum -y install gcc-c++ cmake bison-devel ncurses-devel
2、創建mysql的用戶:
useradd -U -s /sbin/nologin mysql
3、創建必要的文件夾,并修改其目錄用戶所有者:
mkdir -pv /usr/local/mysql/etc
mkdir -pv /data/{boost/boost_1_59_0,mysql/{data,log}}
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql:mysql /data/mysql/
4、將boots庫拷貝到boost目錄下
cp /tmp/boost/boost_1_59_0/* /data/boost/boost_1_59_0
chown -R mysql:mysql /data/boost/
5、編譯安裝mysql5.7
cd /tmp
tar xf mysql-5.7.16.tar.gz
cd mysql-5.7.16
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DSYSCONFDIR=/usr/local/mysql/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/data/mysql/log/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 \
-DWITH_BOOST=/data/boost/boost_1_59_0
make && make install
時間比較長
chown -R mysql:mysql /usr/local/mysql
6、配置文件my.cnf
[client]
port = 3306
socket = /data/mysql/log/mysql.sock
[mysql]
default-character-set = utf8
[mysqld]
# file
datadir =/data/mysql/data
basedir = /usr/local/mysql
pid-file =/data/mysql/log/mysqld.pid
log_error = /data/mysql/log/mysql.err
port = 3306
socket=/data/mysql/mysql.sock
user=mysql
character_set_server = utf8
character_set_server = utf8
slow_query_log = 1
slow_query_log_file = /data/mysql/log/slowq.log
long_query_time = 1
log-bin=/data/mysql/log/mysql-bin.log
# temp
max_tmp_tables = 64
tmp_table_size = 512M
slave_load_tmpdir = /data/mysql/log
tmpdir = /data/mysql/log
# session
back_log = 512
skip-name-resolve
max_allowed_packet = 32M
max_connections = 16000
max_connect_errors = 10000
wait_timeout = 28800
table_open_cache = 216
thread_cache_size = 128
query_cache_type = 0
query_cache_size = 0
key_buffer_size = 128M
myisam_sort_buffer_size = 16M
read_buffer_size = 16M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
# innodb
default_storage_engine = InnoDB
innodb_data_home_dir = /data/mysql/data
innodb_data_file_path = ibdata1:256M:autoextend
innodb_log_group_home_dir = /data/mysql/log
innodb_log_files_in_group = 4
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 50
#innodb_thread_concurrency = 24 16
innodb_buffer_pool_size = 1G
innodb_io_capacity = 1500
innodb_use_native_aio = 1
innodb_file_per_table = 1
innodb_open_files = 3000
# others
memlock = 1
performance_schema = 0
# replication
server-id = 150
binlog_format = row
expire_logs_days = 7
relay_log = /data/mysql/log/relay-bin
#replicate_ignore_db = mysql
#slave_skip_errors = 1062
log_slave_updates = 1
skip-slave-start
read_only = 0
sync_binlog = 1
[mysqldump]
default-character-set = utf8
[mysqld-5.7]
innodb_buffer_pool_dump_pct = 40
innodb_undo_log_truncate = 1
innodb_undo_tablespaces = 3
innodb_max_undo_log_size = 1G
innodb_purge_rseg_truncate_frequency = 128
binlog_gtid_simple_recovery=1
log_timestamps=system
show_compatibility_56=on
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
7、初始化數據庫
版本在5.7.6前用的是mysql_install_db
版本5.7.6之后使用的mysqld --initialize
#####################官網標注#####################################
shell> bin/mysql_install_db --user=mysql # MySQL 5.7.5
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
#####################官網標注#####################################
/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql
可能會出現內存不夠的報錯,自己優化下調節一下buffer大小就行了
/usr/local/mysql/bin/mysql_ssl_rsa_setup
沒有打印日志,臨時密碼不能用,只好破解了,后面有方法。
8、啟動數據庫
vim /usr/local/mysql/support-files/mysql.server
加上絕對路徑
basedir=/usr/local/mysql
datadir=/data/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
service mysqld start
9、配置環境變量
vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
source /etc/profile
10、查看mysql臨時密碼,這項我這不用了,不好使,直接破解了。
cat /root/.mysql_secret
mysql -uroot -p`cat /root/.mysql_secret`
如果能進去,基本上到這就截止了,可以正常使用了。
**不能正常登錄,使用臨時密碼無法登進去**
11、破解密碼
mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --skip-grant-tables --skip-networking&
update mysql.user set authentication_string=password('123456') where user='root';
11.1、查找進程號,殺掉mysql進程
ps aux | grep mysql
kill -9 pid
service mysqld start
11.2、登錄mysql
mysql -u root -p 'password'
提示修改密碼:
mysql> alter user root@localhost identified by '123456';
看了以上CentOS6.9系統編譯安裝MySQL5.7.16教程介紹,希望能給大家在實際運用中帶來一定的幫助。本文由于篇幅有限,難免會有不足和需要補充的地方,大家可以繼續關注億速云行業資訊板塊,會定期給大家更新行業新聞和知識,如有需要更加專業的解答,可在官網聯系我們的24小時售前售后,隨時幫您解答問題的。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。