欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

CentOS下MySQL的安装

程序员文章站 2022-03-09 14:09:49
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
CentOS下MySQL的安装
[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