您好,登錄后才能下訂單哦!
導讀:
本文主要介紹 CentOS 系統二進制安裝 MySQL 5.7.23 版本的安裝步驟,其他版本安裝過程相似。
卸載舊版MySQL
rpm -qa|grep mysql
若有可用rpm -e
卸載
find / -name mysql
安裝相關依賴
yum -y install make gcc-c++ cmake bison-devel ncurses-devel numactl libaio
創建用戶和用戶組
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
# 注冊開機啟動服務
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服務
service mysql start
# 使用初始密碼登錄mysql服務 并修改密碼
mysql -uroot -p
alter user 'root'@'localhost' identified by 'root';
flush privileges;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。