Centos6.8下安装MySQL5.7.17

来源:互联网 发布:windows应用商店的游戏 编辑:程序博客网 时间:2024/06/06 12:43

查看Centos版本

[root@slaver2 ~]# cat /etc/redhat-release CentOS release 6.8 (Final)

查看系统中是否已安装mysql,如果安装就卸载

##查看是否安装[root@slaver2 ~]# rpm -qa | grep mysqlmysql-libs-5.1.73-8.el6_8.x86_64##如果安装进行卸载[root@slaver2 ~]# rpm -e mysqlerror: package mysql is not installed[root@slaver2 ~]# rpm -e --nodeps mysqlerror: package mysql is not installed##如果没有安装,把包进行移除[root@slaver2 ~]# yum -y remove mysql-libs

下载MySQL数据库

我本地已经把mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar下载好了,没有的可以登录到官网进行下载。用WinScp软件上传到Centos服务器上。

##查看包中的文件[root@slaver2 mycloud]# tar -tf  mysql-5.7.17-1.el6.x86_64.rpm-bundle.tarmysql-community-test-5.7.17-1.el6.x86_64.rpmmysql-community-embedded-5.7.17-1.el6.x86_64.rpmmysql-community-embedded-devel-5.7.17-1.el6.x86_64.rpmmysql-community-server-5.7.17-1.el6.x86_64.rpmmysql-community-libs-compat-5.7.17-1.el6.x86_64.rpmmysql-community-devel-5.7.17-1.el6.x86_64.rpmmysql-community-client-5.7.17-1.el6.x86_64.rpmmysql-community-libs-5.7.17-1.el6.x86_64.rpmmysql-community-common-5.7.17-1.el6.x86_64.rpm
##解压到Mysql文件夹下[root@slaver2 mycloud]# tar -xf  mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar -C ./mysql

创建MySQL用户名和用户组

[root@slaver2 mysql]# groupadd -r mysql[root@slaver2 mysql]# useradd -r -g mysql -s /bin/false -M mysql

安装文件,应严格顺序进行安装

##安装依赖包rpm -ivh mysql-community-common-5.7.17-1.el6.x86_64.rpmrpm -ivh mysql-community-libs-5.7.17-1.el6.x86_64.rpm##安装客户端rpm -ivh  mysql-community-client-5.7.17-1.el6.x86_64.rpm##安装服务端rpm -ivh  mysql-community-server-5.7.17-1.el6.x86_64.rpm

初始化mysql

mysql安装完成后,需要初始化root 用户获得初始密码

[root@slaver2 mysql]# mysqld --initialize --user=mysql

临时密码存在mysql.log内容下

[root@slaver2 mysql]# cat /var/log/mysqld.log |grep password2017-05-03T06:11:50.136597Z 1 [Note] A temporary password is generated for root@localhost: ie8su.rjFCp:

启动mysql服务

[root@slaver2 mysql]# /etc/init.d/mysqld statusmysqld is stopped[root@slaver2 mysql]# /etc/init.d/mysqld startStarting mysqld:                                           [  OK  ]

登录mysql,并修改密码

[root@slaver2 mysql]# mysql -uroot -pie8su.rjFCp:mysql> alter user 'root'@'localhost'  identified  by  '123456';mysql> exitmysql> mysql -uroot -pEnter password:mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || sys                |+--------------------+4 rows in set (0.00 sec)mysql> 

设置MySQL开机自启动

##查看是否开启[root@slaver2 mysql]# chkconfig --list |grep mysqlmysqld          0:off   1:off   2:off   3:on    4:on    5:on    6:off##如果没开启,执行语句[root@slaver2 mysql]# chkconfig --level 345 mysqld on

到此处mysql已经安装完成,mysq配置文件my.cnf

具体配置信息

[root@slaver2 mysql]# cat /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 = 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[root@slaver2 mysql]# 

参考文章:http://blog.csdn.net/u012456926/article/details/50166287

0 0
原创粉丝点击