mysql二进制安装

1、mysql server软件下载:https://downloads.mysql.com/archives/get/file/mysql-5.7.17-linux-glibc2.5-x86_64.tar

2、创建用户和用户组:

[root@localhost local]# groupadd mysql

[root@localhost local]# useradd -g mysql mysql

3、mysql安装目录规划:

[root@localhost db3306]# mkdir -p /data1/db3306/data  (数据文件目录)

[root@localhost db3306]# mkdir -p /data1/db3306/binlog  (binlog文件目录)

[root@localhost db3306]# mkdir -p /etc/mysql/   (配置文件目录)

[root@localhost db3306]# chown -R mysql:mysql /data1/

4、解压mysql安装包,修改文件名

[root@localhost local]# cd /usr/local/

[root@localhost local]# tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz 

[root@localhost local]# mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql

5、准备配置文件

[root@localhost local]# cd /etc/mysql/

[root@localhost mysql]# vim app3306.cnf (粘贴下面配置文件)

[mysqld]
# GENERAL #
user                           = mysql
port                           =3306
default_storage_engine         = InnoDB
socket                         = /data1/db3306/data/my3306.sock
pid_file                       = /data1/db3306/data/mysql.pid
#read-only =0
tmpdir                  = /data1/tmp
#key_buffer_size                = 128M
max_allowed_packet             = 32M
max_connect_errors             = 1000000
datadir          = /data1/db3306/data/
log_bin = /data1/db3306/binlog/2201293306-bin
relay-log=  2201293306-relay-bin
expire_logs_days               = 7
sync_binlog                    = 1
tmp_table_size                 = 32M
max_heap_table_size            = 32M
max_connections                = 5000
thread_cache_size              = 512
table_definition_cache         = 4096
table_open_cache               = 4096
wait_timeout            = 28800
interactive_timeout     = 28800
transaction-isolation = READ-COMMITTED
binlog-format=row
character-set-server=utf8
skip-name-resolve
back_log=1024
explicit_defaults_for_timestamp=true
server_id=2


# INNODB #
innodb_flush_method            = O_DIRECT
#innodb_data_home_dir = /data1/db3306
innodb_data_file_path = ibdata1:100M:autoextend
#redo log
#innodb_log_group_home_dir=./
innodb_log_files_in_group      = 3
innodb_log_file_size           = 128M
#innodb performance
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table          = 1
innodb_buffer_pool_instances   = 8
innodb_io_capacity             = 2000
innodb_lock_wait_timeout       = 30
binlog_error_action = ABORT_SERVER
innodb_buffer_pool_size        = 128M
innodb_max_dirty_pages_pct=90
innodb_file_format=Barracuda

innodb_support_xa=0
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_load_at_startup = 1

log_error                      = /data1/db3306/data/error.log


#log_queries_not_using_indexes = 1
slow_query_log                 = 1
slow_query_log_file            = /data1/db3306/data/slow-queries.log
long_query_time=2
gtid_mode=ON
enforce-gtid-consistency
log-slave-updates
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync_master_info = 10000
slave_sql_verify_checksum=1
skip-slave-start
init-connect='SET NAMES utf8'
character-set-server=utf8
skip-character-set-client-handshake
bind-address=0.0.0.0
skip-external-locking
slave-parallel-workers=6


[mysql5.6]
myisam_recover                 = FORCE,BACKUP


粘贴完后,保存文件!

6、目录授权:

[root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost mysql]# chown -R mysql:mysql /data1/

[root@localhost mysql]# chown -R mysql:mysql /etc/mysql/

7、执行安装命令:[root@localhost mysql]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/mysql/app3306.cnf --initialize --user=mysql

8、启动mysql、查询默认密码、登入mysql、修改root密码

启动:[root@localhost data]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/mysql/app3306.conf &

查询默认密码:[root@localhost data]# cat /data1/db3306/data/error.log | grep temp


登入mysql:[root@localhost data]# mysql -S /data1/db3306/data/my3306.sock -uroot -p


修改root密码:mysql> set password=password('mysql');
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

9、配置mysql环境变量:

[root@localhost data]# vim /etc/profile  (加入:export PATH=$PATH:/usr/local/mysql/bin)


[root@localhost data]# source /etc/profile  (重新加载profile文件)

10、安装完毕!!!

阅读更多
上一篇CentOS6.5安装sysbench测试mysql
下一篇mysql表空间
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭