码迷,mamicode.com
首页 > 数据库 > 详细

CentOS7安装MySQL5.7.20

时间:2019-12-07 20:57:12      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:article   rm -rf   install   col   htm   ack   tar   stop   ges   

参考1:https://www.cnblogs.com/technology-huangyan/p/10484838.html

参考1:https://blog.csdn.net/aiyowei1106/article/details/88703746

  emmmm,今天克隆了一台虚拟机,安装MySQL时真是困难重重,这笔账我必须仔细记下来,以警后人哈哈哈哈。

  不管是在Linux下还是Windows下,如果出现某些“巧合”的话,安装MySQL都会困难重重呀。这篇文章就记录一下今天在CentOS7下安装MySQL的辛酸过程。

首先卸载删除操作:

  1、如果开启了mysql进程的话,先kill掉!!!

  技术图片

 

 

   2、查看所有已安装的mysql安装包

   查看方法1:

  技术图片

 

 

    查看方法2:

  技术图片

 

 

   3、全部卸载:

  rpm -e --nodeps MySQL-client.x86_64

  rpm -e --nodeps MySQL-server.x86_64

  4、删除:

  先查询:

  whereis mysql和find / -name mysql,把查出来的目录全删了!

  例如:rm -rf /var/lib/mysql  这一步很重要,否则会报错:而且不能进了lib目录下只删除mysql,否则无效,还是报错。报错原因参考第二个链接。

  技术图片

 

 

   继续删:rm –rf /usr/my.cnf  rm -rf /root/.mysql_sercret  

  删除mysql开机自启动服务:chkconfig --list | grep -i mysql  chkconfig --del mysqld

然后安装:

  1、wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

  2、rpm -ivh mysql57-community-release-el7-8.noarch.rpm 

  3、yum -y install mysql-server(也可以指定安装目录     yum --installroot=/usr/local/mysql --releasever=/ -y install mysql-server)

  4、一些配置文件和脚本默认的位置:

  配置文件:/etc/my.cnf 
  日志文件:/var/log/var/log/mysqld.log 
  服务启动脚本:/usr/lib/systemd/system/mysqld.service 
  socket文件:/var/run/mysqld/mysqld.pid

  5、修改vim /etc/my.cnf

# 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 = 1
expire_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

最后启动MySQL:service mysqld restart  

  首次启动后去mysqld.log中找临时密码(没启动没得):grep "password" /var/log/mysqld.log 

  技术图片

 

 

  然后输入命令:mysql -u root -p

  这是首次登陆,必须重置密码,否则什么也不能操作。

  技术图片

  重置密码命令:alter user ‘root‘@‘localhost‘ identified by ‘Lsj199712.’;需要包含大小写字母,数字,和特殊字符

  技术图片

  最后刷新权限:flush privileges,然后就可以查看操作数据库了。

附:Mysql启动命令:service mysqld start,systemctl start mysqld.service。Mysql重启命令:service mysqld restart。Mysql关闭命令:service mysqld stop,systemctl stop mysqld.service。查看Mysql状态:systemctl status mysqld.service。

  

CentOS7安装MySQL5.7.20

标签:article   rm -rf   install   col   htm   ack   tar   stop   ges   

原文地址:https://www.cnblogs.com/superlsj/p/12003243.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!