CentOS下MySQL的安装

2019-01-02 14:14:32来源:cnblogs.com作者:btyer人点击

分享

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.gzln -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 = utf8port    = 3306socket  = /tmp/mysql.sock[mysqld]character-set-server = utf8replicate-ignore-db = mysqlreplicate-ignore-db = testreplicate-ignore-db = information_schemauser    = mysqlport    = 3306socket  = /tmp/mysql.sockbasedir = /usr/local/mysqldatadir = /data/data0/mysql/3306/datalog-error = /data/data0/mysql/3306/mysql_error.logpid-file = /data/data0/mysql/3306/mysql.pidopen_files_limit    = 10240back_log = 600max_connections = 5000max_connect_errors = 99999#table_cache = 614external-locking = FALSEmax_allowed_packet = 32Msort_buffer_size = 1Mjoin_buffer_size = 1Mthread_cache_size = 300#thread_concurrency = 8query_cache_size = 512Mquery_cache_limit = 2Mquery_cache_min_res_unit = 2kdefault-storage-engine = Innodbthread_stack = 192Ktransaction_isolation = READ-COMMITTEDtmp_table_size = 246Mmax_heap_table_size = 246M#long_query_time = 3log-slave-updateslog-bin = /data/data0/mysql/3306/binlog/binlogbinlog_cache_size = 4Mbinlog_format = MIXEDmax_binlog_cache_size = 8Mmax_binlog_size = 1Grelay-log-index = /data/data0/mysql/3306/relaylog/relaylogrelay-log-info-file = /data/data0/mysql/3306/relaylog/relaylogrelay-log = /data/data0/mysql/3306/relaylog/relaylogexpire_logs_days = 30key_buffer_size = 256Mread_buffer_size = 1Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recoversql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLESinteractive_timeout = 288000wait_timeout = 288000skip-name-resolve#master-connect-retry = 10slave-skip-errors = 1032,1062,126,1114,1146,1048,1396#master-host     =   192.168.1.2#master-user     =   username#master-password =   password#master-port     =  3306server-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]quickmax_allowed_packet = 32M[mysql]no-auto-rehashprompt = (/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

相关文章

    无相关信息

微信扫一扫

第七城市微信公众平台