Centos7 RPM 安装 mysql5.7

来源:互联网 发布:淘宝手机贷款 编辑:程序博客网 时间:2024/05/19 18:17

首先 yum list installed grep |grep maria
然后 yum remove maria******* 进行卸载默认安装的mariadb
1. 去官网下载 mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar 然后使用
tar -xf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar 命令解压
2. 安装mysql(顺序不能乱)
rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm

注意:如果出现缺少某些依赖包,请使用yum安装

3. 使用rpm安装方式安装mysql,安装的路径如下:
a 数据库目录
/var/lib/mysql/
b 配置文件
/usr/share/mysql(mysql.server命令及配置文件)
c 相关命令
/usr/sbin/mysqld
d 启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
e 配置文件
/etc/my.conf
4. 修改配置文件
vim /etc/my.conf

[client]default-character-set=utf8# 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 = 2Mdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid#关闭密码强度认证插件validate_password=offdefault-storage-engine=INNODBcharacter-set-server=utf8collation-server=utf8_general_ci
  1. 为了保证数据库目录为与文件的所有者为 mysql 登陆用户,如果你是以 root 身份运行 mysql 服务,需要执行下面的命令初始化
/user/sbinmysqld --initialize --user=mysql
如果是以 mysql 身份运行,则可以去掉 --user 选项。另外 --initialize 选项默认以“安全”模式来初始化,则会为 root 用户生成一个密码并将该密码标记为过期,登陆后你需要设置一个新的密码,而使用 --initialize-insecure 命令则不使用安全模式,则不会为 root 用户生成一个密码。这里演示使用的 --initialize 初始化的,会生成一个 root 账户密码,密码在log文件(/log/mysql.log |temporary password(具体位置))里,红色区域的就是自动生成的密码![这里写图片描述](http://img.blog.csdn.net/20170516223731264?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjE1NzM4OTk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
  1. 启动mysql
    systemctl start mysqld.service
  2. 执行mysql初始化命令
    mysql_secure_installation

9 然后 重置密码 移除匿名用户,root用户远程登陆等

原创粉丝点击