您好,登錄后才能下訂單哦!
導(dǎo)讀:
本文主要介紹 CentOS 系統(tǒng)二進(jìn)制安裝 MySQL 5.7.23 版本的安裝步驟,其他版本安裝過程相似。
卸載舊版MySQL
rpm -qa|grep mysql
若有可用rpm -e
卸載
find / -name mysql
安裝相關(guān)依賴
yum -y install make gcc-c++ cmake bison-devel ncurses-devel numactl libaio
創(chuàng)建用戶和用戶組
groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql
cd /usr/local/
# wget下載或者本地下載后上傳
wget https://downloads.mysql.com/archives/get/file/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
# 解壓安裝包
tar -zxvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
# 解壓后為了方便后面操作可把解壓后文件名修改為mysql
mv mysql-5.7.23-linux-glibc2.12-x86_64 mysql
# 更改文件夾所屬
chown -R mysql.mysql /usr/local/mysql/
mkdir -p /data/mysql/{data,logs,tmp}
# 更改文件夾所屬
chown -R mysql.mysql /data/mysql/
vi /etc/my.cnf
# 簡單模板如下:
[client]
port = 3306
socket = /data/mysql/tmp/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/data
port = 3306
socket = /data/mysql/tmp/mysql.sock
pid-file = /data/mysql/tmp/mysqld.pid
tmpdir = /data/mysql/tmp
skip_name_resolve = 1
symbolic-links=0
max_connections = 2000
group_concat_max_len = 1024000
sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
lower_case_table_names = 1
log_timestamps=SYSTEM
character-set-server = utf8
interactive_timeout = 1800
wait_timeout = 1800
max_allowed_packet = 32M
binlog_cache_size = 4M
sort_buffer_size = 2M
read_buffer_size = 4M
join_buffer_size = 4M
tmp_table_size = 96M
max_heap_table_size = 96M
max_length_for_sort_data = 8096
#logs
server-id = 1003306
log-error = /data/mysql/logs/error.log
slow_query_log = 1
slow_query_log_file = /data/mysql/logs/slow.log
long_query_time = 3
log-bin = /data/mysql/logs/binlog
binlog_format = row
expire_logs_days = 15
log_bin_trust_function_creators = 1
relay-log = /data/mysql/logs/relay-bin
relay-log-recovery = 1
relay_log_purge = 1
#innodb
innodb_file_per_table = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_flush_neighbors = 0
innodb_flush_method = O_DIRECT
innodb_autoinc_lock_mode = 2
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_buffer_pool_size = 2G
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysql
vi /etc/init.d/mysql
# 修改目錄位置
basedir=/usr/local/mysql
datadir=/data/mysql/data
# 注冊開機(jī)啟動服務(wù)
chkconfig --add mysql
chkconfig --list
echo "PATH=$PATH:/usr/local/mysql/bin " >> /etc/profile
source /etc/profile
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
# 臨時密碼保存在errlog中
# 獲取臨時密碼
more /data/mysql/logs/error.log |grep password
# 啟動mysql服務(wù)
service mysql start
# 使用初始密碼登錄mysql服務(wù) 并修改密碼
mysql -uroot -p
alter user 'root'@'localhost' identified by 'root';
flush privileges;
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。