centos7.3下二进制安装mysql5.7.19记录

本文详细记录了 MySQL 5.7 的二进制安装过程及遇到的问题解决办法,包括配置 my.cnf 文件、解决 libaio.so.1 缺失问题、初始化数据库和启动服务等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2017年10月18号,小雨,现在是9点38分。由于搭建liferay7.0不支持旧版本的数据库,所以今天要二进制安装mysql5.7了,不知道会出现什么样的问题。。。
首先看一下二进制安装包里面的文件

[chenshuai@cs mysql]$ ls
bin  COPYING  docs  include  lib  man  README  share  support-files

现在过去了15分钟了,由于版本的变化,我发现我好像不会。好吧,我先去看下官方文档吧。好的,现在是14点38分,继续,我喜欢把创建的文件放到一个文件夹下,所以在mysql中新建了一个生产目录的 selfadd 目录,然后在里面用 vi 创建my.cnf 配置文件( 别看里面这么多东西,好多没用的!):

[chenshuai@cs selfadd]$ vi my.cnf
###################BASIC#################
[mysqld]
port      = 3306
user      = mysql
socket    = /home/chenshuai/mysql/selfadd/mysql.sock
pid-file  = /home/chenshuai/mysql/selfadd/mysql.pid
basedir   = /home/chenshuai/mysql
datadir   = /home/chenshuai/mysql/selfadd/data
#skip-name-resolve
#skip-grant-tables
skip-external-locking
character-set-server=utf8
default-storage-engine = innodb
lower_case_table_names=1
##################CONNECT#################
max_connections = 2000
max_connect_errors = 1000000
interactive_timeout = 28800
wait_timeout = 28800
connect_timeout = 20
back_log = 500
#FOR FAST CREATE THREAD
thread_cache_size = 300
open_files_limit = 10240
table_open_cache = 3000
###############THREAD BUFFER##############
###############FOR EVERY THREAD###########
sort_buffer_size = 1M
join_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 1M
#net_buffer_length = 16k
tmp_table_size = 64M
max_allowed_packet = 128M
#FOR MEMORY ENGINE
max_heap_table_size = 64M
#################BUFFER##################
###############FOR ALL THREAD############
query_cache_type = 0
query_cache_size = 32M
query_cache_limit = 1M
#################LOG BUFFER#############
binlog_cache_size = 16M
max_binlog_cache_size = 32M
binlog_stmt_cache_size = 32M
#################LOG FILE###############
sync_binlog = 0
binlog_format = row
log-error         = /home/chenshuai/mysql/selfadd/mysql-err.log
#log-bin           = /home/chenshuai/mysql/selfadd/log/master-bin
max_binlog_size = 512M
#relay-log         = /home/chenshuai/mysql/selfadd/log/relay-bin
log_output = file
slow_query_log = 1
slow_query_log_file = /home/chenshuai/mysql/selfadd/log/slow_query.log
long_query_time=10
general_log = 0
general_log_file  = /home/chenshuai/mysql/selfadd/log/general_query_log
expire-logs-days = 3
###############INNODB##################
innodb_log_buffer_size = 8m
innodb_max_dirty_pages_pct = 90
innodb_thread_concurrency = 0
innodb_flush_method = O_DIRECT
innodb_flush_log_at_trx_commit = 0
innodb_lock_wait_timeout = 100
innodb_fast_shutdown = 1
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_io_capacity = 1000
innodb_use_native_aio = 1
innodb_stats_on_metadata = 0
innodb_strict_mode = 1
innodb_file_format = barracuda
innodb_file_format_max = barracuda
innodb_file_format_check = 1
###############MYISAM###################
key_buffer_size = 64M
key_cache_block_size = 64k
myisam_sort_buffer_size = 64M
#################REPLICATE###############
server_id =1
log_slave_updates=1
#######GTID#######
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
err-log  = /home/chenshuai/mysql/selfadd/log/mysqld_safe.log
pid-file = /home/chenshuai/mysql/selfadd/data/mysql.pid
[mysql]
no-auto_rehash
default_character-set = gbk
[client]
port = 3306
socket = /home/chenshuai/mysql/selfadd/mysql.sock
"my.cnf" [New] 119L, 3513C written                            
[chenshuai@cs selfadd]$ ls
my.cnf

可以看到已经创建好了 my.cnf 了。然后回到 mysql 目录下初始化数据库:

[chenshuai@cs mysql]$ bin/mysqld --initialize --user=chenshuai --basedir=/home/chenshuai/mysql  --datadir=/home/chenshuai/mysql/selfadd/data --pid-file=/home/chenshuai/mysql/selfadd/data/mysql.pid
bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

出现这个错误是因为缺少依赖包,我们需要安装一下:

[chenshuai@cs mysql]$ sudo yum install -y libaio
[sudo] password for chenshuai: 
Loaded plugins: fastestmirror
base                                                     | 3.6 kB     00:00     
epel                                                     | 4.3 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
(1/7): base/7/x86_64/group_gz                              | 156 kB   00:00     
(2/7): epel/x86_64/group_gz                                | 170 kB   00:00     
(3/7): extras/7/x86_64/primary_db                          | 110 kB   00:00     
(4/7): epel/x86_64/updateinfo                              | 841 kB   00:00     
(5/7): base/7/x86_64/primary_db                            | 5.7 MB   00:01     
(6/7): updates/7/x86_64/primary_db                         | 2.9 MB   00:01     
(7/7): epel/x86_64/primary_db                              | 4.8 MB   00:01     
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch            Version                    Repository     Size
================================================================================
Installing:
 libaio          x86_64          0.3.109-13.el7             base           24 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 24 k
Installed size: 38 k
Downloading packages:
libaio-0.3.109-13.el7.x86_64.rpm                           |  24 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libaio-0.3.109-13.el7.x86_64                                 1/1 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                 1/1 

Installed:
  libaio.x86_64 0:0.3.109-13.el7                                                

Complete!

然后再执行以下:

[chenshuai@cs mysql]$ bin/mysqld --initialize --user=chenshuai --basedir=/home/chenshuai/mysql  --datadir=/home/chenshuai/mysql/selfadd/data --pid-file=/home/chenshuai/mysql/selfadd/data/mysql.pid
2017-10-18T06:36:24.416816Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-18T06:36:26.467320Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-10-18T06:36:26.687113Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-10-18T06:36:26.810394Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: aaca389e-b3ce-11e7-bb9f-00163e0a4495.
2017-10-18T06:36:26.812383Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-10-18T06:36:26.813434Z 1 [Note] A temporary password is generated for root@localhost: jRy2njkM-uo5

咦呵!还给我警告,不过最后也出来数据库密码了,先记下了,以后再慢慢研究。然后我就启动一下子:

[chenshuai@cs mysql]$ ./bin/mysqld --defaults-file=./selfadd/my.cnf &
[1] 20705
[chenshuai@cs mysql]$ ps -ef |grep mysql
chenshu+ 20705 20262  1 15:28 pts/0    00:00:00 ./bin/mysqld --defaults-file=./selfadd/my.cnf
chenshu+ 20743 20262  0 15:29 pts/0    00:00:00 grep --color=auto mysql

嗯!看样子是启动了,用刚才的随机密码进入一下试试:

[chenshuai@cs mysql]$ ./bin/mysql --defaults-file=./selfadd/my.cnf -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19-log

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> 

还不错,进来了,那我们就修改密码吧!

mysql> alter user 'root'@'localhost' identified by '666666';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

这里我将密码修改为666666,然后退出。现在是15点40分,发表!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值