MySQL installation under CentOS

Keywords: MySQL Database Linux socket

Mysql database is a common database. When you practice the installation, you may encounter various problems. Please refer to the installation method of MySQL database in CentOS system. If you have any questions, please leave a message and I will answer them at any time.

MySQL installation steps are as follows:

Step 1: upload MySQL binary installation package

MySQL version: 5.6.3

Download link: https://pan.baidu.com/s/1uvqAjDP6PRNWHlNt5tyvKQ

Step 2: add user groups and create users

groupadd mysql    // Add a user group named mysql      
useradd  -g mysql mysql // And create a user mysql

Step 3: decompress and create a soft link

cd /usr/local/
tar zxvf  mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
ln -s mysql-5.6.34-linux-glibc2.5-x86_64  mysql

Step 4: create a data directory and modify the owner's group

mkdir -p /data/data0/mysql/3306/data/    
mkdir -p /data/data0/mysql/3306/binlog/  
mkdir -p /data/data0/mysql/3306/relaylog/ 

chown -R mysql:mysql /data/data0/mysql/ 

Step 5: initialize the data (automatically create several libraries and add the record test mysql)

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/data0/mysql/3306/data --user=mysql

Step 6: create a profile

touch /data/data0/mysql/3306/my.cnf   // Create an empty file
vi /data/data0/mysql/3306/my.cnf
[client]
character-set-server = utf8
port    = 3306
socket  = /tmp/mysql.sock

[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user    = mysql
port    = 3306
socket  = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/data0/mysql/3306/data
log-error = /data/data0/mysql/3306/mysql_error.log
pid-file = /data/data0/mysql/3306/mysql.pid
open_files_limit    = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 99999
#table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = Innodb
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
#long_query_time = 3
log-slave-updates
log-bin = /data/data0/mysql/3306/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /data/data0/mysql/3306/relaylog/relaylog
relay-log-info-file = /data/data0/mysql/3306/relaylog/relaylog
relay-log = /data/data0/mysql/3306/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
interactive_timeout = 288000
wait_timeout = 288000

skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

#master-host     =   192.168.1.2
#master-user     =   username
#master-password =   password
#master-port     =  3306

server-id = 1

#innodb_additional_mem_pool_size = 16M
#innodb_buffer_pool_size = 512M
#innodb_data_file_path = ibdata1:512M:autoextend
#innodb_file_io_threads = 4
#innodb_thread_concurrency = 8
#innodb_flush_log_at_trx_commit = 2
#innodb_log_buffer_size = 16M
#innodb_log_file_size = 128M
#innodb_log_files_in_group = 3
#innodb_max_dirty_pages_pct = 90
#innodb_lock_wait_timeout = 120
#innodb_file_per_table = 0

#log-slow-queries = /data/data0/mysql/3306/slow.log
#long_query_time = 2

[mysqldump]
quick
max_allowed_packet = 32M

[mysql]
no-auto-rehash
prompt = (\u@\h)[\d]>\_
default-character-set=utf8
configuration file

After installation, start MySQL.

/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/data0/mysql/3306/my.cnf &

Test for successful installation.

/usr/local/mysql/bin/mysql -uroot -p

Posted by roze on Sun, 01 Dec 2019 12:26:41 -0800