返回顶部
首页 > 资讯 > 数据库 >01-mysql安装篇(rpm方式安装+二进制方式安装)
  • 303
分享到

01-mysql安装篇(rpm方式安装+二进制方式安装)

mysql数据库mysql安装linux运维 2023-09-07 07:09:25 303人浏览 独家记忆
摘要

01-Mysql安装篇(rpm方式安装+二进制方式安装) 一、rpm方式安装1、检查是否安装了mariadb2、下载mysql3、上传解压4、安装5、检查安装6、开启mysql服务7、登陆my

01-Mysql安装篇(rpm方式安装+二进制方式安装)

在这里插入图片描述

一、rpm方式安装

1、检查是否安装了mariadb

[root-mysql ~]# rpm -qa|grep mariadbmariadb-libs-5.5.68-1.el7.x86_64[root-mysql ~]# 

卸载清除: rpm -e 文件名

[root-mysql ~]# rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps[root-mysql ~]# [root-mysql ~]# rpm -qa|grep mariadb  [rootdb-mysql ~]# 

2、下载mysql

官网地址:https://downloads.mysql.com/arcHives/commUnity/

在这里插入图片描述

3、上传解压

[root-mysql ~]# mkdir mysql-bundle[root-mysql mysql-bundle]# tar -xvf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tarmysql-community-client-5.7.37-1.el7.x86_64.rpmmysql-community-common-5.7.37-1.el7.x86_64.rpmmysql-community-devel-5.7.37-1.el7.x86_64.rpmmysql-community-embedded-5.7.37-1.el7.x86_64.rpmmysql-community-embedded-compat-5.7.37-1.el7.x86_64.rpmmysql-community-embedded-devel-5.7.37-1.el7.x86_64.rpmmysql-community-libs-5.7.37-1.el7.x86_64.rpmmysql-community-libs-compat-5.7.37-1.el7.x86_64.rpmmysql-community-server-5.7.37-1.el7.x86_64.rpmmysql-community-test-5.7.37-1.el7.x86_64.rpm[root-mysql mysql-bundle]# 

4、安装

## 安装mysql所依赖的包[root-mysql mysql-bundle]# rpm -ivh mysql-community-common-5.7.37-1.el7.x86_64.rpmwarning: mysql-community-common-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEYPreparing...                          ################################# [100%]Updating / installing...   1:mysql-community-common-5.7.37-1.e################################# [100%][root-mysql mysql-bundle]# rpm -ivh mysql-community-libs-5.7.37-1.el7.x86_64.rpmwarning: mysql-community-libs-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEYPreparing...                          ################################# [100%]Updating / installing...   1:mysql-community-libs-5.7.37-1.el7################################# [100%][root-mysql mysql-bundle]# rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpmwarning: mysql-community-client-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEYPreparing...                          ################################# [100%]Updating / installing...   1:mysql-community-client-5.7.37-1.e################################# [100%][root-mysql mysql-bundle]# ## 安装mysql服务[root-mysql mysql-bundle]# rpm -ivh mysql-community-server-5.7.37-1.el7.x86_64.rpmwarning: mysql-community-server-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEYerror: Failed dependencies:net-tools is needed by mysql-community-server-5.7.37-1.el7.x86_64[root-mysql mysql-bundle]# 

报错:error: Failed dependencies:
net-tools is needed by mysql-community-server-5.7.37-1.el7.x86_64

解决:

[root-mysql mysql-bundle]# yum install -y net-tools[root-mysql mysql-bundle]# yum install -y perl[root-mysql mysql-bundle]# yum install -y libaio
## 再次安装mysql服务[root-mysql mysql-bundle]# rpm -ivh mysql-community-server-5.7.37-1.el7.x86_64.rpmwarning: mysql-community-server-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEYPreparing...                          ################################# [100%]Updating / installing...   1:mysql-community-server-5.7.37-1.e################################# [100%][root-mysql mysql-bundle]# 

5、检查安装

[root-mysql mysql-bundle]# rpm -qa|grep mysqlmysql-community-common-5.7.37-1.el7.x86_64mysql-community-libs-5.7.37-1.el7.x86_64mysql-community-client-5.7.37-1.el7.x86_64mysql-community-server-5.7.37-1.el7.x86_64[root-mysql mysql-bundle]#

6、开启mysql服务

[root-mysql mysql-bundle]# systemctl start mysqld[root-mysql mysql-bundle]# systemctl status mysqld● mysqld.service - MySQL Server   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)   Active: active (running) since Thu 2022-12-22 10:48:53 CST; 9s aGo     Docs: man:mysqld(8)           Http://dev.mysql.com/doc/refman/en/using-systemd.html  Process: 2190 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)  Process: 2140 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 2194 (mysqld)   CGroup: /system.slice/mysqld.service           └─2194 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pidDec 22 10:48:50 Centos01 systemd[1]: Starting MySQL Server...Dec 22 10:48:53 centos01 systemd[1]: Started MySQL Server.[root-mysql mysql-bundle]# 

7、登陆mysql

第一次启动mysql,会自动生成一个随机密码,可在/var/log/mysqld.log中查看。

[root-mysql ~]# grep "passWord" /var/log/mysqld.log2022-12-22T02:48:50.966917Z 1 [Note] A temporary password is generated for root: q=VIgtgHH7p_2022-12-22T02:54:05.987706Z 2 [Note] Access denied for user 'root'@'localhost' (using password: YES)2022-12-22T02:54:14.598377Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)2022-12-22T02:54:27.747247Z 4 [Note] Access denied for user 'root'@'localhost' (using password: YES)[root-mysql ~]# 

在这里插入图片描述

8、修改密码设置规则(简单型-学习用)

[root mysql-bundle]# mysql -u root -pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)[root mysql-bundle]# mysql -u root -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.37Copyright (c) 2000, 2022, oracle and/or its affiliates.Oracle is a reGIStered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set global validate_password_policy=LOW;Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password_length=4;Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password_mixed_case_count=0;Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password_number_count=0;Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password_special_char_count=0;Query OK, 0 rows affected (0.00 sec)mysql> 

9、修改密码

mysql>  alter user root identified by '123456';Query OK, 0 rows affected (0.00 sec)

10、授权远程登陆

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> 

测试
![在这里图片描述](https://img-blog.csdnimg.cn/f02eadbd2a294ec3bcc526f068e9baa5.png

11、启停mysql命令

## 启动 mysql 服务[root-mysql ~]# systemctl start mysqld## 关闭[root-mysql ~]# systemctl stop mysqld## 重启[root-mysql ~]# systemctl restart mysqld## 状态查看[root-mysql ~]# systemctl status mysqld## 设置开机自启[root-mysql ~]# systemctl enable mysqld

12、rpm方式安装说明

## rpm方式重要文件路径说明主要文件默认路径如下:配置文件路径:/etc/my.cnf数据存储目录:/var/lib/mysql错误日志存储路径:/var/log/mysqld.logSocket文件路径:/var/lib/mysql/mysql.sock参数可以通过/etc/my.cnf参数配置文件查看和自定义。

二、二进制方式安装V5.7.18

1、上传解压

[root-mysql mysql-tar]# tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

在这里插入图片描述

2、创建安装目录

[root-mysql mysql-tar]# mkdir /usr/local/mysql

在这里插入图片描述

3、拷贝解压后的文件至安装目录/usr/local/mysql/

[root-mysql ~]# mv mysql-5.7.18-linux-glibc2.5-x86_64/* /usr/local/mysql/

在这里插入图片描述
在这里插入图片描述

4、创建相关目录

[root-mysql mysql]# mkdir /usr/local/mysql/data[root-mysql mysql]# [root-mysql mysql]# mkdir /usr/local/mysql/log[root-mysql mysql]# [root-mysql mysql]# touch /usr/local/mysql/log/mysqld.log[root-mysql mysql]# [root-mysql mysql]# 

在这里插入图片描述

5、创建mysql组和用户

[root-mysql mysql]# groupadd mysql[root-mysql mysql]# [root-mysql mysql]# useradd -r -g mysql mysql[root-mysql mysql]# 

6、更改安装目录归属

[root-mysql mysql]# chown -R mysql /usr/local/mysql/[root-mysql mysql]# chgrp -R mysql /usr/local/mysql/

或者使用:

[root-mysql mysql]# chown -R mysql:mysql /usr/local/mysql

在这里插入图片描述

7、初始化MySQL

[root-mysql mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize

在这里插入图片描述

8、 配置MySQL

[root-mysql mysql]# vi /etc/my.cnf
[mysqld]datadir=/usr/local/mysql/databasedir=/usr/local/mysqlsocket=/tmp/mysqld.sockuser=mysqlport=3306character-set-server=utf8skip-grant-tablessymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid[client]socket=/tmp/mysqld.sock

在这里插入图片描述

9、启动MySQL

[root-mysql mysql]# cd support-files/[root-mysql support-files]# sh mysql.server startStarting MySQL. SUCCESS! [root-mysql support-files]#

在这里插入图片描述
查看MySQL服务是否启动成功

[root-mysql support-files]# sh mysql.server status SUCCESS! MySQL running (2294)[root-mysql support-files]#

10、配置环境变量

[root-mysql support-files]# vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin

在这里插入图片描述

使配置生效

[root-mysql support-files]# source /etc/profile

11、允许root账号远程访问

[root-mysql support-files]# mysql -u root -p

在这里插入图片描述
修改mysql数据库密码报错:
ERROR 1290 (HY000): The MySQL Server is running with the --skip-grant-tables option so it cannot execute this statement.

解决:先刷新权限表

mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)

在这里插入图片描述

12、设置mysql服务开机自启

[root-mysql mysql]# systemctl status mysqld

报错: Unit mysqld.service could not be found.

[root-mysql mysql]# find / -name mysql.server/usr/local/mysql/support-files/mysql.server[root-mysql mysql]# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld[root-mysql mysql]# systemctl enable mysqldmysqld.service is not a native service, redirecting to /sbin/chkconfig.Executing /sbin/chkconfig mysqld on[root-mysql mysql]# systemctl status mysqld● mysqld.service - LSB: start and stop MySQL   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)   Active: inactive (dead)     Docs: man:systemd-sysv-generator(8)[root-mysql mysql]# 

13、mysql服务启动

[root-mysql mysql]# systemctl start mysqld[root-mysql mysql]# systemctl status mysqld● mysqld.service - LSB: start and stop MySQL   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)   Active: active (exited) since 三 2023-05-10 18:28:08 CST; 2s ago     Docs: man:systemd-sysv-generator(8)  Process: 10873 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)510 18:28:08 db-mysql systemd[1]: Starting LSB: start and stop MySQL...510 18:28:08 db-mysql mysqld[10873]: Starting MySQL SUCCESS!510 18:28:08 db-mysql systemd[1]: Started LSB: start and stop MySQL.510 18:28:08 db-mysql mysqld[10873]: 2023-05-10T10:28:08.620811Z mysqld_safe A mysqld process already exists[root-mysql mysql]# 

来源地址:https://blog.csdn.net/qq_41840843/article/details/130616685

您可能感兴趣的文档:

--结束END--

本文标题: 01-mysql安装篇(rpm方式安装+二进制方式安装)

本文链接: https://lsjlt.com/news/397817.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • 01-mysql安装篇(rpm方式安装+二进制方式安装)
    01-mysql安装篇(rpm方式安装+二进制方式安装) 一、rpm方式安装1、检查是否安装了mariadb2、下载mysql3、上传解压4、安装5、检查安装6、开启mysql服务7、登陆my...
    99+
    2023-09-07
    mysql 数据库 mysql安装 linux 运维
  • mysql安装rpm方式
    查看系统中安装的rpm包rpm -qa | grep mysql卸载自带的mysqlrpm  -e  --nodeps   * 解压mysqltar -xv...
    99+
    2024-04-02
  • 二进制安装mysql 5.7、mariadb (附yum安装方式)
     前言:        本文以mariadb为例进行讲解,安装mysql同理,并以通过测试。安装前查找系统已安装的相关包(rpm -qa|grep -e "mysql" -e "mariadb")并进行卸载...
    99+
    2024-04-02
  • Linux Centos7安装MySQL5.5(二进制方式安装)
    Linux Centos7安装MySQL5.5(二进制方式安装) 一、在/app目录下下载mysql-5.5.54-linux2.6-x86_64.tar.gz` [root@test /]# cd /ap...
    99+
    2024-04-02
  • MySQL 5.7.22 rpm 安装方式
    在MySQL官网下载安装包 [root@hashow-db-master resource]# tar -xvf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar [ro...
    99+
    2024-04-02
  • MySQL的rpm安装方式
    本篇内容主要讲解“MySQL的rpm安装方式”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL的rpm安装方式”吧!用于安装MySQL的rpm包如下:Ta...
    99+
    2024-04-02
  • SuSE11安装MySQL5.7.22:RPM安装方式
    摘要:SuSE11sp3 64位操作系统、 MySQL5.7.22 rpm安装包5.7版本与先前版本安装有所区别,需要注意注:kingtry是我的主机名一、环境准备操作系统:SuSE版本11sp3...
    99+
    2024-04-02
  • SuSE11安装MySQL5.6.40:RPM安装方式
    摘要:SuSE11sp3 64位操作系统、 MySQL5.6.40rpm安装包注:kingtry是我的主机名一、环境准备操作系统:SuSE版本11sp3,64位kingtry:~ #&n...
    99+
    2024-04-02
  • MySQL 5.6.35 RPM包方式的安装
    Mysql 5.6.35版本 RPM包方式的安装 一.删除旧的RPM包: 查询 rpm -qa | grep -i mysql如果有需要先删除rpm -ev mysql-libs- --nodepsrpm ...
    99+
    2024-04-02
  • 如何用rpm方式安装mysql
    小编给大家分享一下如何用rpm方式安装mysql,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!查看安装以及卸载# 查看 rpm ...
    99+
    2024-04-02
  • 二进制方式安装mysql 5.7.19的最新方法
    下文我给大家简单讲讲关于二进制方式安装mysql 5.7.19的最新方法,大家之前了解过相关类似主题内容吗?感兴趣的话就一起来看看这篇文章吧,相信看完二进制方式安装mysql 5.7.19的最新方法对大家多...
    99+
    2024-04-02
  • 安装MySQL(Yum方式安装)
    安装MySQL(Yum方式安装) #设置主机名 本次安装5.7版本 hostnamectl --static set-hostname mysql #查看内核 [root@mysql ~]# cat ...
    99+
    2023-09-04
    mysql 数据库 linux
  • centos6上以二进制方式安装mariadb5.5
    准备mariadb-5.5.57-linux-x86_64.tar.gz二进制程序包此包是经过编译的,也就是说我们要在特定的目录下安装;步骤1、准备mysql用户mkdir /app/data#此目录是存放...
    99+
    2024-04-02
  • 如何使用rpm方式安装mysql
    今天就跟大家聊聊有关如何使用rpm方式安装mysql,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。查看安装以及卸载# 查看 rpm&nb...
    99+
    2024-04-02
  • MySQL安装方式
    一、单实例_rpm1、上传安装包tar -xf mysql-5.7.24-1.el6.x86_64.rpm-bundle.tar2、检查是否安装 rpm -qa | grep -i mysql rpm -q...
    99+
    2024-04-02
  • Centos7.5安装mysql5.7.24二进制包方式部署
    一、环境准备: 操作系统:CentOS Linux release 7.5.1804 (Core) mysql版本:mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz IP...
    99+
    2024-04-02
  • Linux内网离线安装nginx(rpm包安装方式)
    1、下载RPM离线安装包: 首先,先下载nginx的rpm包,下载地址:http://nginx.org/packages/centos/7/x86_64/RPMS/ 下载nginx-1.18.0-2.el7.ngx.x86_64.rp...
    99+
    2023-08-31
    linux nginx 运维 服务器 Powered by 金山文档
  • Mysql二进制安装
    Mysql安装安装步骤1、新建用户groupadd mysqluseradd -r -g mysql mysqlcd /usr/local/----------------------------注意路径c...
    99+
    2024-04-02
  • Centos8安装mysql8的详细过程(免安装版/或者二进制包方式安装)
    目录二进制包方式安装一、首先检查服务器上是否安装有mysql:二、开始安装配置mysql在Navicat上测试连接二进制包方式安装 一、首先检查服务器上是否安装有mysql: 第一步:查看mysql安装版本rpm -qa...
    99+
    2024-04-02
  • Centos7怎么用rpm方式安装mysql-5.5
    这篇文章主要讲解了“Centos7怎么用rpm方式安装mysql-5.5”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Centos7怎么用rpm方式安装my...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作