cent0s7下安装配置mysql

本文档详细介绍了如何在Linux系统上下载、安装、初始化MySQL,并提供了配置文件示例,包括设置端口、数据目录、用户权限等。通过步骤2.4的初始化和2.5的启动命令,成功启动数据库服务。最后,指导了如何登录MySQL并修改root用户的默认密码,确保了系统的安全运行。

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

一、下载mysql

//官网
https://dev.mysql.com/downloads/mysql/

二、安装

2.1 将mysql包上传至linux并解压

tar -zxvf mysql-8.0.25-el7-x86.tar.gz

2.2 将解压的文件复制到/usr/local/mysql目录

cp mysql-8.0.25-el7-x86.tar.gz /usr/local/mysql

2.3 修改/etc/my.conf文件

[client]
port=3306
socket=/data/mysql/mysql.sock
[mysqld]
port=3306
user=root
socket=/data/mysql/mysql.sock
basedir=/usr/local/mysql/mysql-8.0.25-el7-x86_64
datadir=/usr/local/mysql/mysql-8.0.25-el7-x86_64/data
log-error=/data/mysql/error.log
pid-file = /data/mysql/mysql.pid
transaction_isolation = READ-COMMITTED
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
lower_case_table_names = 1
default_authentication_plugin=mysql_native_password

# Disabling symbolic-links is recommended to prevent assorted security risks

# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

2.4 初始化mysql

cd /software/mysql/bin
./mysqld --user=mysql --basedir=/software/mysql --datadir=/data/mysql --initialize

2.5 启动mysql

/software/mysql/support-files/mysql.server start

2.6 登录mysql

/software/mysql/bin/mysql -u root –p

初始密码可查看:/data/mysql/error.log文件

2.7 修改密码

>mysql  set password=password('root');

>mysql  grant all privileges on *.* to root@'%' identified by 'root';

>mysql  flush privileges;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值