centos7 Mariadb建立多例項

2021-08-15 12:21:17 字數 3515 閱讀 4964

為了對mycat做實驗,於是建立多例項mariadb,做以下筆記:

建立多例項資料庫資料夾:

[root@linux-node1 ~]# mkdir /home/multimysql

[root@linux-node1 ~]# mkdir /home/multimysql/

[root@linux-node1 ~]# mkdir /home/multimysql/datadir/

[root@linux-node1 ~]# chmod -r 777 /home/multimysql

初始化例項:

$ mysql_install_db --basedir=/usr --datadir=/home/multimysql/datadir/3307 --user=mysql

$ mysql_install_db --basedir=/usr --datadir=/home/multimysql/datadir/3308 --user=mysql

$ mysql_install_db --basedir=/usr --datadir=/home/multimysql/datadir/3309 --user=mysql

$ mkdir /home/multimysql/etc/my.cnf.d/

#vim /home/multimysql/etc/my.cnf.d/my.cnf

[mysqld]

skip-name-resolve

lower_case_table_names=1

innodb_file_per_table=1

back_log = 50

max_connections = 300

max_connect_errors = 1000

table_open_cache = 2048

max_allowed_packet = 16m

binlog_cache_size = 2m

max_heap_table_size = 64m

sort_buffer_size = 2m

join_buffer_size = 2m

thread_cache_size = 64

thread_concurrency = 8

query_cache_size = 64m

query_cache_limit = 2m

ft_min_word_len = 4

default-storage-engine = innodb

thread_stack = 192k

transaction_isolation = repeatable-read

tmp_table_size = 64m

log-bin=mysql-bin

binlog_format=row

slow_query_log

long_query_time = 1

server-id = 1

key_buffer_size = 8m

read_buffer_size = 2m

read_rnd_buffer_size = 2m

bulk_insert_buffer_size = 64m

myisam_sort_buffer_size = 128m

myisam_max_sort_file_size = 10g

myisam_repair_threads = 1

myisam_recover

innodb_additional_mem_pool_size = 16m

innodb_buffer_pool_size = 200m

innodb_data_file_path = ibdata1:10m:autoextend

innodb_file_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 16m

innodb_log_file_size = 512m

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 60

innodb_lock_wait_timeout = 120

[mysqldump]

quick

max_allowed_packet = 256m

[mysql]

no-auto-rehash

prompt=\\u@\\d \\r:\\m>

[myisamchk]

key_buffer_size = 512m

sort_buffer_size = 512m

read_buffer = 8m

write_buffer = 8m

[mysqlhotcopy]

interactive-timeout

[mysqld_safe]

open-files-limit = 8192

vim /home/multimysql/etc/3307.cnf

3307.cnf 檔案內容如下:

[client]

port = 3307

socket = /home/multimysql/socket/mysql3307.sock

[mysqld]

datadir=/home/multimysql/datadir/3307

port = 3307

server_id =1

socket = /home/multimysql/socket/mysql3307.sock

!includedir /home/multimysql/etc/my.cnf.d

3308.cnf 如下:

[client]

port = 3308

socket = /home/multimysql/socket/mysql3308.sock

[mysqld]

datadir=/home/multimysql/datadir/3308

port = 3308

socket = /home/multimysql/socket/mysql3308.sock

啟動例項:

/usr/bin/mysqld_safe --defaults-file=/home/multimysql/etc/3307.cnf &

連線例項:

mysql -u root -s /home/multimysql/socket/mysql3307.sock

centos7 mariadb 設定root密碼

修改root密碼 1.以root身份在終端登陸,必須 2.輸入 mysqladmin u root p password root 後面的 root 是要設定的密碼 3.回車後出現 enter password 輸入就密碼,如果沒有,直接回車 建立使用者 建立使用者 mysql insert int...

CentOS7 mariadb 修改編碼

centos7 mariadb 編碼的修改 網上看了不少的解決方案,要麼是比較老的,要麼是不正確,測試成功的方式,記錄備查。登入mysql,使用show variables like character 檢視當前使用的字符集,應該有好幾個不是utf 8格式。要修改的配置檔案位於 etc my.cnf...

centos7系統安裝Mariadb

從最新版本的centos系統開始,使用命令yum install mysql 預設安裝的是 mariadb而不是mysql!yum install mariadb mariadb server systemctl start mariadb 啟動mariadb systemctl enable ma...