Centos安装MySQL(RPM安装方式)

Centos安装MySQL(RPM安装方式)

1、centos中以rpm安装包的方式进行安装测试

2、在MySQL官网下载安装包官网下载
Product Version:5.7.33
Operating System:Red Hat Enterprise Linux / Oracle Linux
OS Version:All
下载
mysql-community-common-5.7.33-1.el7.x86_64.rpm
mysql-community-libs-5.7.33-1.el7.x86_64.rpm
mysql-community-client-5.7.33-1.el7.x86_64.rpm
mysql-community-server-5.7.33-1.el7.x86_64.rpm
或者下载mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar再解压出上述四个rpm文件

3、通过远程工具把文件传送到指定目录(MobaXterm是一款很好用的远程工具)
我把文件放到/usr/local/dev/mysql目录下
在这里插入图片描述

4、查看系统中是否存在mysql或者mariadb数据库及相关组件
#rpm -qa|grep mysql
#rpm -qa|grep mariadb
若存在相关组件,需要先进行清除
#rpm -e xxx --nodeps

5、按照依赖关系依次安装rpm包 依赖关系依次为common→libs→client→server
#rpm -ivh mysql-community-common-5.7.33-1.el7.x86_64.rpm
#rpm -ivh mysql-community-libs-5.7.33-1.el7.x86_64.rpm
#rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm
#rpm -ivh mysql-community-server-5.7.33-1.el7.x86_64.rpm
如下图所示,安装完毕。
Centos安装MySQL(RPM安装方式)_第1张图片

6、打开配置文件(my.cnf),进行相关配置
#vi /etc/my.cnf
这里设置了一下lower_case_table_names和sql_mode,为了和windows环境一致,具体含义不在介绍。其他配置保持默认。

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M


## 默认值是0,为了与开发环境兼容,这里修改成了1
lower_case_table_names=1

#默认有更多的限制,为了与开发环境兼容,做了调整
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

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

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

7、启动MySQL并查看MySQL启动状态
#systemctl start mysqld
#systemctl status mysqldCentos安装MySQL(RPM安装方式)_第2张图片

8、查看MySQL生成的临时密码
cat /var/log/mysqld.log |grep password
在这里插入图片描述

9、使用临时密码登录MySQL系统并修改默认密码
#mysql -uroot -pG.sb416hhyc!
#alter user ‘root’@‘localhost’ identified by ‘Test@1234’;
#flush privileges;
Centos安装MySQL(RPM安装方式)_第3张图片

10、之后就可以正常操作mysql了,要想其他机器可以通过ip访问,可以通过update语句把root用户的Host属性改成%后重启服务,并设置(关闭)防火墙。不在赘述。

小尾巴~~
只要有积累,就会有进步

你可能感兴趣的:(linux,MySQL,mysql,rpm,linux)