MySQL5.7.18 for Linux7.2如何实现二进制安装
admin
2023-05-25 11:41:36
0

具体的做法如下:

1、下载二进制软件包:

   mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

2、添加MySQL用户和组:

   [root@localhost ~]# userdel mysql   (因为是新系统,所以就把现有的MySQL用户给删除了)

   [root@localhost ~]# groupadd mysql

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

   [root@localhost ~]# passwd mysql      (MySQL密码要设置的复杂一点,或者在创建用户的时候设置不让登陆系统)

3、创建安装MySQL目标,并解压软件到指定目录

   [root@localhost ~]# mkdir -p /mysql/data

   [root@localhost ~]# chown -R mysql.mysql /mysql

   [root@localhost ~]# tar zxvf  mysql-5.7.18-linux-glibc2.5-x86_64 -C /mysql

   [root@localhost ~]# cd /mysql

   [root@localhost ~]# mv mysql-5.7.18-linux-glibc2.5-x86_64/ mysql5718

   [root@localhost ~]# chown -R mysql.mysql /mysql

4、切换MySQL用户,并初始化数据库

   [root@localhost ~]# su - mysql

   [mysql@localhost ~]$ /mysql/mysql5718/bin/mysqld --initialize --user=mysql --basedir=/mysql/mysql5718/ --datadir=/mysql/data/

    -----注意,初始化数据库会生成登录MySQL数据库的root密码,一定要记住,一会登录数据库要用

5、编辑my.cnf配置文件,启动数据库

[mysql@localhost ~]$ vim my.cnf    (该配置文件仅供参考)

[client]

socket                    = /mysql/data/mysql.sock

default_character_set     = utf8

[mysql]

socket=/mysql/data/mysql.sock

[mysqld]                                                      

server_id                 = 1607                               

port                      = 3306                               

basedir                   = /mysql/mysql5718/                   

datadir                   = /mysql/data/               

socket                    = /mysql/data/mysql.sock     

pid_file                  = /mysql/data/mysql.pid      

log_error                 = /mysql/data/mysql_error.log

log_bin                   = /mysql/data/mysql_bin      

relay_log                 = /mysql/data/relay_bin      

character_set_server      = utf8                               

collation_server          = utf8_general_ci                    

innodb_buffer_pool_size   = 8G                            

innodb_buffer_pool_instances = 8                          

innodb_log_file_size      = 1G                            

innodb_log_files_in_group = 3                             

innodb_log_buffer_size    = 24M                          

innodb_flush_log_at_trx_commit = 1                        

innodb_file_per_table     = 1                             

innodb_flush_method       = O_DIRECT                      

innodb_io_capacity        = 200                           

innodb_io_capacity_max    = 600                           

innodb_thread_concurrency = 0                             

innodb_autoinc_lock_mode  = 2                             

innodb_lock_wait_timeout  = 60                            

innodb_read_io_threads    = 4                 

innodb_write_io_threads   = 4                                  

innodb_max_dirty_pages_pct = 80                                

innodb_autoextend_increment = 512                              

innodb_checksum_algorithm = NONE                               

innodb_doublewrite        = 0                                  

innodb_use_native_aio     = 1                                  

innodb_open_files         = 8192                               

sync_binlog               = 1                                  

sync_relay_log            = 1                                  

relay_log_info_repository = TABLE                              

master_info_repository    = TABLE                              

expire_logs_days          = 10                                 

binlog_format             = ROW                                

transaction-isolation     = READ-COMMITTED                     

concurrent_insert         = 2                                  

skip_slave_start          = TRUE                             

back_log                  = 2000                               

thread_stack              = 256k                               

thread_cache_size         = 256                                

key_buffer_size           = 256M                               

tmp_table_size            = 64M                                

read_buffer_size          = 2M                                 

read_rnd_buffer_size      = 8M                                 

sort_buffer_size          = 2M                                 

join_buffer_size          = 2M                                 

query_cache_size          = 0                                  

query_cache_type          = 0                                  

max_heap_table_size       = 64M                                

binlog_cache_size         = 2M                                 

table_open_cache          = 8192                               

max_allowed_packet        = 64M                                

bulk_insert_buffer_size   = 64M                                

max_connect_errors        = 100000                             

max_connections           = 500                                

connect_timeout           = 300                                

wait_timeout              = 86400                              

interactive_timeout       = 86400                              

lower_case_table_names    = 1                                  

open_files_limit          = 20480                              

skip_name_resolve                                              

skip_external_locking                                          

explicit_defaults_for_timestamp = TRUE                         

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

 [mysql@localhost ~]$  /mysql/mysql5718/bin/mysqld_safe --defaults-file=/mysql/data/my.cnf  --user=mysql &

6、进入数据库检查:

 [mysql@localhost ~]$  /mysql/mysql5718/bin/mysql -u root -p --socket=/mysql/data/mysql.sock

 Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 7

Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password='123456';  (因为刚才使用的密码是个默认的登录密码,所以我们要修改)

mysql>  flush privileges;

然后再重新登录MySQL即可,进行检查

mysql> s\

--------------

/mysql/mysql5718/bin/mysql  Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86_64) using  EditLine wrapper

Connection id:          7

Current database:

Current user:           root@localhost

SSL:                    Not in use

Current pager:          stdout

Using outfile:          ''

Using delimiter:        ;

Server version:         5.7.18-log MySQL Community Server (GPL)

Protocol version:       10

Connection:             Localhost via UNIX socket

Server characterset:    utf8

Db     characterset:    utf8

Client characterset:    utf8

Conn.  characterset:    utf8

UNIX socket:            /mysql/data/mysql.sock

Uptime:                 25 min 16 sec

Threads: 1  Questions: 19  Slow queries: 0  Opens: 110  Flush tables: 1  Open tables: 103  Queries per second avg: 0.012

--------------

mysql> 

这样,二进制的MySQL就顺利安装完成了;

相关内容

热门资讯

厨房油烟机不通风怎么办 厨房油烟机不通风是很常见的问题,这不仅会影响厨房的空气质量,还可能会导致火灾等安全隐患。出现这种情况...
厨房油烟机没有窗户怎么办 如果你的厨房没有窗户,安装油烟机就会更加困难,因为安装油烟机需要一定的通风。 以下是一些解决方案。 ...
厨房抽油烟机倒烟怎么办 厨房抽油烟机倒烟是一个比较常见的问题,特别是在使用时间较长或清洗不及时的情况下。倒烟不仅会影响观感,...
抽油烟机口子打大了怎么办 当抽油烟机口子打大了,通常会发现油烟抽不出去,这是因为空气流动受到影响,也会导致噪音增加和效率下降。...
厨房油烟机隐藏安装方法 厨房油烟机是现代家庭厨房中必不可少的设备之一,它可以有效地吸附和过滤厨房中产生的油烟和异味,保持厨房...
美媒爆料:美以曾试图营救被软禁... 美国和以色列2月份突袭伊朗,并炸死伊朗最高领袖哈梅内伊等高层。据美媒最新爆料,美以曾试图扶植伊朗前总...
哈尔滨一双层巴士被高架桥削顶,... 5月20日,有网民在网络平台发布视频称,哈尔滨市香坊区一辆载有乘客的双层巴士被高架桥横梁“削顶”,车...
“普京把半个国家的内阁和经济班... 俄罗斯总统普京开启对中国国事访问行程。此次随同普京访华的俄方代表团有哪些亮点值得关注?凤凰卫视驻北京...
韩国三星电子劳资谈判再破裂,明... 最新消息:韩国三星电子今天(5月20日)的劳资谈判再度宣告破裂,明天起将举行大罢工。这也将是该公司史...
国台办:赖清德上台两年所作所为... 5月20日,国务院台办举行例行新闻发布会。有记者问,赖清德上台满两年,岛内最新民调显示,台湾民众对于...