CentOS RPM 安装 MySQL5.7

环境

CentOS 7 64位

MySQL 5.7 64位

1.卸载系统自带的 mariadb

[[email protected] /]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] /]# rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps

2.下载RPM包

MySQL官网下载rpm集合包到本地再上传至服务器或通过下面的方法直接在服务器下载

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar

3.解压tar包


[[email protected] softwares]# ls
mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
[[email protected] softwares]# tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
mysql-community-server-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-client-5.7.18-1.el7.x86_64.rpm
mysql-community-common-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-5.7.18-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm
mysql-community-test-5.7.18-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm

4.安装

依次执行(几个包有依赖关系,所以执行有先后)下面命令安装

rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
5.数据库初始化
mysqld --initialize --user=mysql

--initialize 选项默认以“安全”模式来初始化,则会为 root 用户生成一个密码并将该密码标记为过期(密码在/var/log/mysqld.log中),登陆后你需要设置一个新的密码,而使用 --initialize-insecure 命令则不使用安全模式,则不会为 root 用户生成一个密码。

[[email protected] softwares]# more /var/log/mysqld.log
2018-02-24T08:27:17.789803Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-02-24T08:27:18.923811Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-02-24T08:27:18.981104Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-02-24T08:27:19.116973Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 87296646-193c-11e8-adaf-000c29ee8fae.
2018-02-24T08:27:19.332937Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2018-02-24T08:27:19.333647Z 1 [Note] A temporary password is generated for [email protected]: m)6_=8yl6(pA

最后一行给出了MySQL登录密码。

启动MySQL服务,登录MySQL

[[email protected] softwares]# systemctl start mysqld
[[email protected] softwares]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> 

6.重置root用户密码

提示密码过期,需要重置

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

重置密码

ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘new_password‘;
或
mysql> set password for ‘root‘@‘localhost‘=password(‘new_password‘); 

7.远程授权登录

root 用户名

% 所有人都可以访问

password 密码

# 给特定IP授权
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.1.100‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;

# 给任意IP授权
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;

刷新权限

flush privileges;  

8.配置utf8编码

修改/etc/my.cnf,在后面加上下面内容

[mysqld]
character_set_server=utf8
init_connect=‘SET NAMES utf8‘

重启MySQL

systemctl restart mysqld

显示编码

show variables like ‘%character%‘;

参考链接:

1.https://my.oschina.net/Laily/blog/713022

2.http://www.cnblogs.com/maobuji/p/8336702.html

原文地址:https://www.cnblogs.com/flythinking/p/8466921.html

时间: 2024-08-30 12:32:36

CentOS RPM 安装 MySQL5.7的相关文章

centos6.5 rpm安装mysql5.6.19操作及步骤

系统:centos 6.5  64位 数据库:mysql5.6.19 64位 采用RPM安装包安装,之后修改mysql默认路径. 首先要卸载系统自带mysql包,命令如下 yum remove mysql mysql-server mysql-libs 检查是否有残留 rpm -qa | grep mysql 若发现有则使用rpm -e 安装包名称 安装步骤: 1.官网下载tar压缩包,下载地址为http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-5.6

centos6.5 rpm安装mysql5.6.19

1,检查MySQL及相关RPM包,是否安装,如果有安装,则移除. rpm -qa | grep -i mysql yum -y remove mysql-libs* 2,根据系统下载RPM包,我下载的MySQL-5.6.19-1.el6.i686.rpm-bundle.tar 解压压缩包,依次安装: rpm -ivh MySQL-server-5.6.19-1.el6.i686.rpm rpm -ivh MySQL-devel-5.6.19-1.el6.i686.rpm rpm -ivh MyS

Centos成功安装mysql-5.5.37

摘自http://www.2cto.com/os/201404/296364.html(原文请关注) 这几天在centos下装mysql,这里记录一下安装的过程,方便以后查阅 Mysql5.5.37安装需要cmake,5.6版本开始都需要cmake来编译,5.5以后的版本应该也要装这个. 安装cmake [plain] view plaincopyprint?01.[[email protected] ~]# wget http://www.cmake.org/files/v2.8/cmake-

Centos 下安装 mysql5.5.45

又动手安装了一次mysql,版本是5.5.45,5.5以上版本需要安装cmake! 安装流程: 0.先检查是否有自带的mariadb,有则卸载1.安装所需软件: 2.安装CMAKE; 3.tar.gz形式安装mysql: 4.配置与启动: 0.首先centos7 已经不支持mysql,所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以需要先卸载掉mariadb,以下为卸载mariadb,安装mysql的步骤.(妈蛋,之前不知道,我安装了一整天才知道有这个坑,fu

CentOS6.5下RPM安装Mysql5.6

一.升级操作 1.卸载旧版本 查看MySQL旧版本 rpm -qa|grep mysql rpm -qa|grep mariadb 卸载MySQL rpm -e --nodeps mysql-5.1.73-7.el6.x86_64 rpm -e --nodeps mysql-connector-odbc-5.1.5r1144-7.el6.x86_64 rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64 rpm -qa|grep mysql 删除数据目录

Centos下安装Mysql5.7

升级,建议完成后重启 yum -y update 卸载已安装的Mysql yum -y remove mysql-libs 安装依赖 yum -y install numactl-libs 下载安装包 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.19-1.el7.x86_64.rpm wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-

Centos6下rpm安装MySQL5.6

Centos6在rpm安装 rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm yum install mysql-server –y 启动 service mysqld start 初始化 mysql_secure_installation Enter current password for root (enter for none): Set root password? [Y/n] Remo

centos 7安装mysql5.5

首先centos7 已经不支持mysql,因为收费了你懂得,所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以需要先卸载掉mariadb,以下为卸载mariadb,安装mysql的步骤. #列出所有被安装的rpm package rpm -qa | grep mariadb #卸载 rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64 错误:依赖检测失败:        libmysqlclient.so.18()(64bit) 被

centOS6.6系统中rpm安装 MySQL-5.6.30

RPM方式安装MySQL5.6.30 a. 检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称) 1 [[email protected] ~]# rpm -qa | grep -i mysql 2 mysql-libs-5.1.66-2.el6_3.x86_64 3 [[email protected] ~]# yum -y remove mysql-libs* b. 下载Linux对应的RPM包,如:CentOS6.6_64对应的RPM包,如下: 1 [[emai