centos快速安装mysql5.7_Centos7安装MySQL5.7(yum)

本人尝试过使用源码安装方式,那叫一个头疼,各种问题,于是采用yum方式安装,没想到如此简单:

此服务器是刚买的,所以以前没有安装过mysql,如果以前安装过mysql的,好像要卸载干净再安装(其实我也不懂~)。

开始吧:

1、配置yum源

#下载mysql源安装包(默认5.7最新版本)

[[email protected] ~]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm#安装mysql源

[[email protected] ~]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm

检测yum源是否安装成功

[[email protected] ~]# yum repolist enabled | grep "mysql.*-community.*"

20190301182731840375.png

如上图所示即安装成功

2、安装MySQL

[[email protected] ~]# yum -y install mysql-server

等一会就安装好了

20190301182732175336.png

默认配置文件路径:

/etc/my.cnf #配置文件

/var/log/var/log/mysqld.log #日志文件

/usr/lib/systemd/system/mysqld.service #服务启动脚本

/var/run/mysqld/mysqld.pid #socket文件

3、配置 my.cnf

[[email protected] ~]# vim /etc/my.cnf

jia.gif

jian.gif

#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

datadir=/var/lib/mysql

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

server_id= 1expire_logs_days= 3

#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

my.cnf

4、启动mysql服务

[[email protected] ~]# service mysqld restart

5、查看密码(因为安装好后,第一次登录密码为随机密码)

[[email protected] ~]# grep "password" /var/log/mysqld.log

20190301182732501507.png

输入 mysql -u root -p 回车,再输入上面的随机密码,回车,即可登录MySQL。

6、重置密码

注意:

ip处填localhost,不要填%

密码必须包含数字、字母、符号(为了安全)

mysql> alter user "root"@"localhost" identified by "新密码";

20190301182732753461.png

记得要刷新权限

mysql> flush privileges;

exit退出MySQL,再次登录就可以用设置好的密码了。

1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值