centOS7 安装mysql5.7

楼主  收藏   举报   帖子创建时间:  2016-03-22 00:00 回复:0 关注量:301

mysql5.7相比较mysql5.6而言,有很大进步,特别对于安装来说,要简单得多。现将方法简介而下。
前两步和安装mysql5.6相同。
1、卸载mariadb
rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64
###会提示错误:依赖检测失败
###加上–nodeps参数强制卸载
rpm -e –nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
如果找不到就用yum -y remove mariadb-libs.x86_64
2、下载mysql5.7
进入mysql下载官网,点击左上方的“Community”,选择平台“Red Hat Enterprise Linux”,下载此版本下的mysql-5.7.11-1.el7.x86_64.rpm-bundle.tar(大小为520.7M),如果点击Download会提示你要先登录Oracle帐户,如果没有帐户或者不想登录,可以点击下方的“No thanks,just start my download”,也可一个FTP站点下载,里面包含了几乎所有的mysql版本。
3、安装
解压:tar xvf mysql-5.7.11-1.el7.x86_64.rpm-bundle.tar ,先安装“rpm -ivh mysql-community-common-5.7.11-1.el7.x86_64.rpm”,然后“mysql-community-libs-5.7.11-1.el7.x86_64.rpm”,再“mysql-community-client-5.7.11-1.el7.x86_64.rpm”,“mysql-community-devel-5.7.11-1.el7.x86_64.rpm”,最后“mysql-community-server-5.7.11-1.el7.x86_64.rpm”。
安装后mysql的主要文件如下:
MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone

Files or Resources Location
Client programs and scripts /usr/bin
mysqld server /usr/sbin
Configuration file /etc/my.cnf
Data directory /var/lib/mysql
Error log file For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log

 

For SLES: /var/log/mysql/mysqld.log

Value of secure_file_priv /var/lib/mysql-files
System V init script For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld

 

For SLES: /etc/init.d/mysql

Systemd service For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld

 

For SLES: mysql

Pid file /var/run/mysql/mysqld.pid
Socket /var/lib/mysql/mysql.sock
Keyring directory /var/lib/mysql-keyring
Unix manual pages /usr/share/man
Include (header) files/usr/include/mysql
Libraries /usr/lib/mysql
Miscellaneous support files (for example, error messages, and character set files) /usr/share/mysql

3、初始化
切换到root用户,启动服务“service mysqld start”,找到root用户的初始密码“grep ‘temporary password’ /var/log/mysqld.log”,用找到的密码登录root用户“mysql -uroot -p ”,改密码“mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘yourpasswd’; ”。