CentOS下MySQL的安装

前端之家收集整理的这篇文章主要介绍了CentOS下MySQL的安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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 = (\[email protected]\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

猜你在找的CentOS相关文章