二进制安装mysql-5.7.26

本文详细介绍在CentOS系统中安装与配置MySQL 5.7的过程,包括上传与解压软件包、创建目录与用户、初始化数据库、设置参数、启动服务、修改密码及开机自启动等关键步骤。

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

一、上传二进制 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz包

#/data 是数据盘 自己根据情况定
[root@VM_0_10_centos data]# pwd

/data

tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.7.26-linux-glibc2.12-x86_64 mysql
#做软连接 
ln -s /data/mysql /usr/local/mysql

cd /data/mysql

mkdir data
groupadd mysql
useradd -M -g mysql -s /sbin/nologin -d /usr/local/mysql mysql
chown -R mysql.mysql /usr/local/mysql/

rpm -qa | grep maria*
yum -y remove mari*

#安装库
yum install -y libnuma* 

二、mysql 初始化、启动、修改密码、开机自启动

[mysqld]
port=3306
character-set-server=utf8
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
#innodb_buffer_pool_size=8M
max_connections=1000
slow_query_log = 1
slow_query_log_file=/usr/local/mysql/log/mysql_slow_query.log
long_query_time = 5
max_connections=1000
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]

log-error=/usr/local/mysql/data/error.log

pid-file=/usr/local/mysql/data/mysql.pid

tmpdir=/usr/local/mysql/tmp

[client]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysql]
default-character-set=utf8

# 初始化

./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 

 # 配置启动文件

cp ./support-files/mysql.server /etc/init.d/mysqld

vim /etc/init.d/mysqld


#basedir=/usr/local/mysql
#datadir=/usr/local/mysql/data
#mysqld_pid_file_path=/usr/local/mysql/data/mysql.pid

  

#启动数据库
  service mysqld start

#修改密码
 ./bin/mysql -u root -p

SET PASSWORD FOR 'root'@localhost=PASSWORD('Your Password');

#添加环境变量
 vim /etc/profile

export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH

#环境变量生效
 source /etc/profile

#开机自启动

[root@VM_0_14_centos mysql]# chmod +x /etc/rc.d/init.d/mysqld 
[root@VM_0_14_centos mysql]# chkconfig --add mysqld
[root@VM_0_14_centos mysql]# chkconfig --list mysqld

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off

# 如果是centos7 话可以检查一下

systemctl start mysqld 
systemctl stop mysqld  
systemctl status mysqld

 

转载于:https://www.cnblogs.com/zhaojingyu/p/11481741.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值