Mysql 5.7.17 离线版安装和数据迁移(centos 7)

本文详细介绍了如何在CentOS 7上离线安装MySQL 5.7.17,包括下载安装包、上传、解压、安装依赖、初始化数据、配置文件复制、服务脚本设置等关键步骤。

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

1.从官网下载mysql 离线版版安装包 mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz;
2.上传安装包mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz 到 centos 7 的 /usr/tool/ 目录 ;
3.进入/usr/tool/ —> cd /usr/tool;
4.解压安装包:tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz;
5.安装依赖: yum -y install perl perl-devel autoconf libaio;
6.进入/usr/local/mysql/ —>cd /usr/local/mysql/;
7.创建data目录:mkdir /usr/local/mysql/data;
8.添加mysql用户组和用户:
groupadd mysql;
useradd -r -g mysql -s /bin/false mysql;
9. 修改目录拥有者为mysql:chown -R mysql:mysql ./
10.初始化数据(下面是一条语句):
./bin/mysqld --initialize --user=mysql
–basedir=/usr/local/mysql
–datadir=/usr/local/mysql/data
–pid-file=/usr/local/mysql/data/mysql.pid
–tmpdir=/tmp
11.复制生成的密码(登录mysql时用):
12.复制配置文件到/etc/my.cnf:cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y)
13.mysql的服务脚本放到系统服务中:
cp -a ./support-files/mysql.server /etc/init.d/mysqld
14.赋予可执行权限:chmod +x /etc/init.d/mysqld
15.添加服务:chkconfig --add mysqld (可用chkconfig --list命令查看,3,4,5都是ON证明已启动)

16.修改my.cnf文件:vi /etc/my.cnf, 编辑添加如下内容:
log-bin = /home/data/logs/mysql/binlog/mysql-bin #开启二进制日志功能,binlog数据位置
log-bin-index = /home/data/logs/mysql/binlog/mysql-bin.index
log_bin_trust_function_creators = 1
binlog_cache_size = 1M
binlog_format = ROW
expire_logs_days = 30 #超过30天的binlog删除

max_connections = 500 #最大连接数
port = 3306
socket = /tmp/mysql.sock
pid-file = /usr/local/mysql/mysql.pid
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log_error =/home/data/logs/mysql/mysql-error.log
user = mysql

character-set-server = utf8
back_log = 1024
server-id = 1

long_query_time = 1 #开启慢查询
slow_query_log = 2 #慢查询时间(s)
slow_query_log_file = /home/data/logs/mysql/mysql-slow.log

>>>>>>以下是在线安装5.7版本的

[root@CentOS ~]# yum install -y mysql-server
[root@CentOS ~]# service mysqld start
[root@CentOS ~]# mysqladmin -u root password 'root'
[root@CentOS ~]# mysql -u root -proot
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> delete from user where password='';
Query OK, 4 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

2、进入/etc/mysql/mysql.conf.d 目录下的 mysqld.cnf 文件中需要把下面以上注释掉,使所以主机都可以链接
bind-address = 127.0.0.1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值