REHL6安装MySQL

时间:2019-02-20
本文章向大家介绍REHL6安装MySQL,主要包括REHL6安装MySQL使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

title: REHL6安装Mysql
categories: Linux
tags:
- MySQL
timezone: Asia/Shanghai
date: 2019-02-01

环境

方法1:在线采用官方YUM方式安装MySQL5.7

如需要安装其他版本只需要修改mysql-community.repo内容即可。

# 1.设置官方yum源
rpm -ivh https://repo.mysql.com//mysql80-community-release-el6-1.noarch.rpm

# 2.在这里我们选择安装5.7版本,只保留以下内容,其他所有内容删除
vim /vim /etc/yum.repos.d/mysql-community.repo

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# 3.开始安装
yum install -y mysql-community-server.x86_64

# 4.启动MySQL数据库
service mysqld start
chkconfig mysqld on
service mysqld status
chkconfig --list mysqld

# 5.修改root密码并登录数据库

sudo grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
mysql> ALTER USER root@localhost IDENTIFIED BY 'Xiaoliu123!';
mysql> exit;

方法2:用下载好的rpm包离线安装

# 1.上传服务器并安装
yum install -y mysql-community-client-5.7.24-1.el6.x86_64.rpm \
                mysql-community-common-5.7.24-1.el6.x86_64.rpm \
                mysql-community-libs-5.7.24-1.el6.x86_64.rpm \
                mysql-community-libs-compat-5.7.24-1.el6.x86_64.rpm \
                mysql-community-server-5.7.24-1.el6.x86_64.rpm

# 2.启动MySQL数据库
service mysqld start
chkconfig mysqld on
service mysqld status
chkconfig --list mysqld

# 3.修改root密码并登录数据库

sudo grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
mysql> ALTER USER root@localhost IDENTIFIED BY 'Xiaoliu123!';
mysql> exit;

附录:离线rpm包下载地址

百度网盘下载:

https://pan.baidu.com/s/1o0-UikLptJZg_FWqCVpGyA

官网下载:

http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-client-5.7.24-1.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-libs-5.7.24-1.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-libs-compat-5.7.24-1.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-server-5.7.24-1.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-common-5.7.24-1.el6.x86_64.rpm

附录:

MySQL Yum存储库:https://dev.mysql.com/downloads/repo/yum/

MySQL Server Initialization (as of MySQL 5.7): At the initial start up of the server, the following happens, given that the data directory of the server is empty:
MySQL服务器初始化(从MySQL 5.7开始):在服务器初始启动时,如果服务器的数据目录为空,则会发生以下情况:

The server is initialized.
服务器已初始化。

An SSL certificate and key files are generated in the data directory. 在数据目录中生成SSL证书和密钥文件。

The validate_password plugin is installed and enabled.
validate_password插件已安装并启用。

A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
创建超级用户帐户“root”@“localhost”。 设置超级用户的密码并将其存储在错误日志文件中。 要显示它,请使用以下命令:
shell> sudo grep 'temporary password' /var/log/mysqld.log