linux没有yum命令

人气:289 ℃/2023-01-29 19:07:12

linux系统下没有yum命令怎么解决呢?下面是具体操作步骤:

1、切换到root用户身份。普通用户切换为root用户:在终端运行命令 sudo -s。

2、检测是否安装了build-essential程序包,输入命令:apt-get install build-essential。

3、安装yum,输入命令:apt-get install yum。

4、yum安装成功即可。

以上就是小编今天的分享了,希望可以帮助到大家。

安装yum命令的方法

使用yum方式安装MySQL8.0

1.配置yum仓库

#更新密钥

RPM --import https://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/

#安装MySQL8.x数据库版本的yum库

[root@dbserver ~]# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm

获取https://dev.MySQL.com/get/mysql80-community-release-el7-2.noarch.rpm

警告:/var/tmp/rpm-tmp.rK9iDv: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

准备中... ################################# [100%]

正在升级/安装...

1:mysql80-community-release-el7-2 ################################# [100%]

[root@dbserver ~]#

2.使用yum安装mysql8.0

[root@dbserver ~]# yum repolist |grep mysql

mysql-connectors-community/x86_64 MySQL Connectors Community 206

mysql-tools-community/x86_64 MySQL Tools Community 94

mysql80-community/x86_64 MySQL 8.0 Community Server 367

[root@dbserver ~]#

[root@dbserver ~]# yum -y install mysql-community-server

已加载插件:fastestmirror, langpacks

Loading mirror speeds from cached hostFile

* base: mirror.lzu.edu.cn

* extras: mirror.lzu.edu.cn

* updates: mirror.lzu.edu.cn

正在解决依赖关系

--> 正在检查事务

---> 软件包 mysql-community-server.x86_64.0.8.0.31-1.el7 将被 安装

--> 正在处理依赖关系 mysql-community-common(x86-64) = 8.0.31-1.el7,它被软件包 mysql-community-server-8.0.31-1.el7.x86_64 需要

--> 正在处理依赖关系 mysql-community-icu-data-files = 8.0.31-1.el7,它被软件包 mysql-community-server-8.0.31-1.el7.x86_64 需要

--> 正在处理依赖关系 mysql-community-client(x86-64) >= 8.0.11,它被软件包 mysql-community-server-8.0.31-1.el7.x86_64 需要

--> 正在检查事务

---> 软件包 mysql-community-client.x86_64.0.8.0.31-1.el7 将被 安装

--> 正在处理依赖关系 mysql-community-client-plugins = 8.0.31-1.el7,它被软件包 mysql-community-client-8.0.31-1.el7.x86_64 需要

--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.11,它被软件包 mysql-community-client-8.0.31-1.el7.x86_64 需要

---> 软件包 mysql-community-common.x86_64.0.8.0.31-1.el7 将被 安装

---> 软件包 mysql-community-icu-data-files.x86_64.0.8.0.31-1.el7 将被 安装

--> 正在检查事务

---> 软件包 mysql-community-client-plugins.x86_64.0.8.0.31-1.el7 将被 安装

---> 软件包 mysql-community-libs.x86_64.0.8.0.31-1.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

============================================================================================================================

Package 架构 版本 源 大小

============================================================================================================================

正在安装:

mysql-community-server x86_64 8.0.31-1.el7 mysql80-community 64 M

为依赖而安装:

mysql-community-client x86_64 8.0.31-1.el7 mysql80-community 16 M

mysql-community-client-plugins x86_64 8.0.31-1.el7 mysql80-community 2.5 M

mysql-community-common x86_64 8.0.31-1.el7 mysql80-community 647 k

mysql-community-icu-data-files x86_64 8.0.31-1.el7 mysql80-community 2.1 M

mysql-community-libs x86_64 8.0.31-1.el7 mysql80-community 1.5 M

事务概要

============================================================================================================================

安装 1 软件包 ( 5 依赖软件包)

总下载量:87 M

安装大小:409 M

Downloading packages:

(1/6): mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm | 2.5 MB 00:00:03

(2/6): mysql-community-common-8.0.31-1.el7.x86_64.rpm | 647 kB 00:00:00

(3/6): mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm | 2.1 MB 00:00:00

(4/6): mysql-community-client-8.0.31-1.el7.x86_64.rpm | 16 MB 00:00:04

(5/6): mysql-community-libs-8.0.31-1.el7.x86_64.rpm | 1.5 MB 00:00:00

(6/6): mysql-community-server-8.0.31-1.el7.x86_64.rpm | 64 MB 00:00:09

----------------------------------------------------------------------------------------------------------------------------

总计 5.8 MB/s | 87 MB 00:00:14

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

警告:RPM 数据库已被非 yum 程序修改。

** 发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下:

2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit)

2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit)

正在安装 : mysql-community-client-plugins-8.0.31-1.el7.x86_64 1/6

正在安装 : mysql-community-common-8.0.31-1.el7.x86_64 2/6

正在安装 : mysql-community-libs-8.0.31-1.el7.x86_64 3/6

正在安装 : mysql-community-client-8.0.31-1.el7.x86_64 4/6

正在安装 : mysql-community-icu-data-files-8.0.31-1.el7.x86_64 5/6

正在安装 : mysql-community-server-8.0.31-1.el7.x86_64 6/6

验证中 : mysql-community-server-8.0.31-1.el7.x86_64 1/6

验证中 : mysql-community-common-8.0.31-1.el7.x86_64 2/6

验证中 : mysql-community-client-plugins-8.0.31-1.el7.x86_64 3/6

验证中 : mysql-community-icu-data-files-8.0.31-1.el7.x86_64 4/6

验证中 : mysql-community-client-8.0.31-1.el7.x86_64 5/6

验证中 : mysql-community-libs-8.0.31-1.el7.x86_64 6/6

已安装:

mysql-community-server.x86_64 0:8.0.31-1.el7

作为依赖被安装:

mysql-community-client.x86_64 0:8.0.31-1.el7 mysql-community-client-plugins.x86_64 0:8.0.31-1.el7

mysql-community-common.x86_64 0:8.0.31-1.el7 mysql-community-icu-data-files.x86_64 0:8.0.31-1.el7

mysql-community-libs.x86_64 0:8.0.31-1.el7

完毕!

[root@dbserver ~]#

3.安装完成后启动MySQL

[root@dbserver ~]# systemctl status mysqld

● mysqld.service - MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: active (running) since 五 2022-11-25 10:01:11 CST; 14s ago

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

Process: 2229 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

Main PID: 2311 (mysqld)

Status: "Server is operational"

CGroup: /system.slice/mysqld.service

└─2311 /usr/sbin/mysqld

11月 25 10:01:10 dbserver systemd[1]: Starting MySQL Server...

11月 25 10:01:11 dbserver systemd[1]: Started MySQL Server.

[root@dbserver ~]#

#MySQL安装完成以后,自动配置产生服务文件/usr/lib/systemd/system/mysqld.service,可以被systemctl管理

4.配置为开机自动启动

[root@dbserver ~]# systemctl is-enabled mysqld

enabled

[root@dbserver ~]# systemctl enable mysqld

[root@dbserver ~]# more /usr/lib/systemd/system/mysqld.service

# Copyright (c) 2015, 2022, Oracle and/or its affiliates.

#

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License, version 2.0,

# as published by the Free Software Foundation.

#

# This program is also distributed with certain software (including

# but not limited to OpenSSL) that is licensed under separate terms,

# as designated in a particular file or component or in included license

# documentation. The authors of MySQL hereby grant you an additional

# permission to link the program and your derivative works with the

# separately licensed software that they have included with MySQL.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License, version 2.0, for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#

# systemd service file for MySQL forking server

#

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

Type=notify

# Disable service start and stop timeout logic of systemd for mysqld service.

TimeoutSec=0

# Execute pre and post scripts as root

PermissionsStartOnly=true

# Needed to create system tables

ExecStartPre=/usr/bin/mysqld_pre_systemd

# Start main service

ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS

# Use this to switch malloc implementation

EnvironmentFile=-/etc/sysconfig/mysql

# Sets open_files_limit

LimitNOFILE = 10000

Restart=on-failure

RestartPreventExitStatus=1

# Set enviroment variable MYSQLD_PARENT_PID. This is required for restart.

Environment=MYSQLD_PARENT_PID=1

PrivateTmp=false

[root@dbserver ~]#

5.查看安装产生的临时密码,登录数据库

[root@dbserver ~]# grep ' temporary password' /var/log/mysqld.log

2022-11-25T10:01:50.495268Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ;5?Xy,di5lP=

[root@dbserver ~]#

[root@dbserver ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 8.0.31

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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> alter user 'root'@'localhost' identified with mysql_native_password by 'Mysql2022!';

Query OK, 0 rows affected (0.00 sec)

7.配置root的简单密码

mysql>

mysql> set global validate_password.policy=0;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> set global validate_password.length=5;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456';

Query OK, 0 rows affected (0.02 sec)

mysql>

mysql> \s

--------------

mysql Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id: 10

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ''

Using delimiter: ;

Server version: 8.0.31 MySQL Community Server - GPL

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8mb4

Db characterset: utf8mb4

Client characterset: utf8mb4

Conn. characterset: utf8mb4

UNIX socket: /var/lib/mysql/mysql.sock

Binary data as: Hexadecimal

Uptime: 10 min 27 sec

Threads: 2 Questions: 17 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.027

--------------

mysql>

8.允许root账户远程登录,并设置远程登录密码(此密码和root本地登录密码可以不同)

mysql> create user 'root'@'%' identified with mysql_native_password by '1234567';

Query OK, 0 rows affected (0.01 sec)

mysql>

mysql> select User,Host,authentication_string from user;

------------------ ----------- ------------------------------------------------------------------------

| User | Host | authentication_string |

------------------ ----------- ------------------------------------------------------------------------

| root | % | *6A7A490FB9DC8C33C2B025A91737077A7E9CC5E5 |

| mysql.infoschema | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |

| mysql.session | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |

| mysql.sys | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |

| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

------------------ ----------- ------------------------------------------------------------------------

5 rows in set (0.00 sec)

mysql>

mysql> alter user 'root'@'%' identified with mysql_native_password by '12345678';

[root@dbserver ~]# netstat -lantup |grep mysql

tcp6 0 0 :::33060 :::* LISTEN 2311/mysqld

tcp6 0 0 :::3306 :::* LISTEN 2311/mysqld

[root@dbserver ~]#

9.退出控制台

Ctrl D或者输入exit

推荐

首页/电脑版/网名
© 2026 NiBaKu.Com All Rights Reserved.