CentOS7安装MySQL步骤

本文详细介绍了在CentOS系统上安装MySQL的过程,包括使用Yum Repository安装,设置数据库,启动与停止服务,配置远程访问,修改字符集,并提供了相应的命令行操作。此外,还涉及了MySQL的权限管理和安全设置。

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

问题:centos安装MySQL

解决:

1、下载并安装MySQL官方的 Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql-community-server

如遇到 mysql-community-client-5.7.39-1.el7.x86_64.rpm 的公钥尚未安装

则执行命令 rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

然后再执行 yum -y install mysql-community-server

2、MySQL数据库设置

启动:systemctl start mysqld.service

# 停止:systemctl stop mysqld.service

# 开机启动:systemctl enable mysqld.service

查看状态:systemctl status mysqld.service

在日志文件中查找密码:grep "password" /var/log/mysqld.log

进入数据库:mysql -uroot -p

修改MySQL密码:mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

3、开启mysql远程访问

mysql> grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;

mysql> flush privileges;

4、更改mysql语言 

打开配置文件:vim /etc/my.cnf

加入以下几行代码:

[client]  
default-character-set=utf8 

default-storage-engine=INNODB  
character-set-server=utf8 
collation-server=utf8_general_ci

5、重启MySQL

6、查看字符状态

登录MySQL查看状态:

mysql> status;

mysql> show variables like 'chara%';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值