MySQL資料庫是一款比較常用的資料庫,大家在練習安裝時,可能會遇到各種各樣的問題,請大家參考在CentOS系統下MySQL資料庫的安裝方式。如有任何問題,歡迎留言,本人隨時解答。 MySQL安裝步驟如下: 第一步:上傳 MySQL二進位安裝包 MySQL版本:5.6.3 下載鏈接:https:// ...
MySQL資料庫是一款比較常用的資料庫,大家在練習安裝時,可能會遇到各種各樣的問題,請大家參考在CentOS系統下MySQL資料庫的安裝方式。如有任何問題,歡迎留言,本人隨時解答。
MySQL安裝步驟如下:
第一步:上傳 MySQL二進位安裝包
MySQL版本:5.6.3
下載鏈接:https://pan.baidu.com/s/1uvqAjDP6PRNWHlNt5tyvKQ
第二步:添加用戶組,創建用戶
groupadd mysql // 添加一個用戶組,名字叫做 mysql
useradd -g mysql mysql // 並創建一個用戶 mysql
第三步:解壓縮,創建軟鏈接
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
第四步:創建數據目錄,並修改所有者所屬組
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/
第五步:初始化數據(自動創建幾個庫,添加記錄 test mysql)
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/data0/mysql/3306/data --user=mysql
第六步:創建配置文件
touch /data/data0/mysql/3306/my.cnf // 創建空文件 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配置文件
安裝完成,啟動MySQL。
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/data0/mysql/3306/my.cnf &
測試是否安裝成功。
/usr/local/mysql/bin/mysql -uroot -p