6

I installed MariaDB on a computer with CentOS using the instructions given here:

MariaDB Package Repository Setup and Usage - MariaDB Knowledge Base

The basic command I used was:

sudo yum install MariaDB-server MariaDB-client  

and I did not install Maxscale or percona.

MariaDB installation has compleetd successfully, but now if I enter a yet uninstalled command in the bash shell, I am getting this error:

Failed to search for file: Failed to download gpg key for repo 'mariadb-main': Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY [Couldn't open file /etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY]

For example, if I enter the command ftp, previously I would have got a message indicating that ftp was not installed, and I would have got some recommendations on which command I meant and would like to download. However, now I get this:

[username@localhost ~]$ ftp
bash: ftp: command not found...
Failed to search for file: Failed to download gpg key for repo 'mariadb-main': Curl error (37):     Couldn't read a file:// file for file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY [Couldn't open file   /etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY]
[username@localhost ~]$

After some searching around I have found that it is because the file etc/yum.repos.d/mariadb.repo has an entry:

gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY    

and the MariaDB-Server-GPG-KEY file does not exist in etc/pki/rpm-gpg

I suppose this should have been created automatically when I installed mariadb? How do I make this bash error go away? Is there any way I can download or create this file manually?

--- EDIT ---
This was resolved as follows:

Downloaded RPM-GPG-KEY-MariaDB as explained in Philip's answer (https://unix.stackexchange.com/a/602962/28907)

Copied it to /etc/pki/rpm-gpg/

In /etc/yum.repos.d/mariadb.repo changed the line gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY to gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MariaDB

Set the gpgcheck for other entries in the mariadb.repo file to 0 (I don't have maxscale and mariadb enterprise installed)

user13267
  • 189
  • 2
  • 12
  • You can import the GPG key manually: https://mariadb.com/kb/en/yum/#importing-the-mariadb-gpg-public-key . However, I'm not sure how it is linked to your shell. – Haxiel May 11 '20 at 13:48
  • @Haxiel already tried this, it didn't work for me. I'm not sure what I'm doing wrong. The command itself does not give any errors, but it doesn't get rid of the "Failed to download gpg key" message, and doesn't create MariaDB-Server-GPG-KEY in /etc/pki/rpm-gpg – user13267 May 11 '20 at 14:19
  • Can you edit the yum repo file to set `gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MariaDB`? The filename for the key is different from the one in your error message. – Haxiel May 11 '20 at 15:00
  • Also, please see this QA for details on how a `yum` command is linked to your shell: https://stackoverflow.com/q/14389684 – Haxiel May 11 '20 at 15:01
  • @Haxiel you mean the file shouldn't be named "MariaDB-Server-GPG-KEY"? – user13267 May 11 '20 at 15:08
  • I checked again, and the documentation seems to contradict itself. There's a key at https://yum.mariadb.org/RPM-GPG-KEY-MariaDB and another key at https://downloads.mariadb.com/MariaDB/MariaDB-Server-GPG-KEY . I'm not sure which is the right one. Can you explain how you set up your `yum` repos? – Haxiel May 11 '20 at 17:09
  • @Haxiel I used the tutorial here: https://mariadb.com/kb/en/mariadb-package-repository-setup-and-usage/, I'm not sure if I understand what exactly setting up repos means in linux, but before installing I executed curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash \ – user13267 May 12 '20 at 00:50
  • That script should automatically handle the keys and repositories for you. Can you run `sudo rpm --import https://downloads.mariadb.com/MariaDB/MariaDB-Server-GPG-KEY` and see if it resolves the problem? – Haxiel May 12 '20 at 06:04
  • @Haxiel I have already tried this and it didn't change anything. I still get the "Failed to download gpg key" error and I don't have the MariaDB-Server-GPG-KEY file inside /etc/pki/rpm-gpg – user13267 May 12 '20 at 06:46
  • @Haxiel I have tried it's variant as well (trying to rpm --import the RPM-GPG-KEY-MariaDB file) and it also doesn't work – user13267 May 12 '20 at 06:47
  • Apparently you have the `PackageKit-command-not-found` RPM package installed. It adds a special customization to the shell's "command not found" error handler, which attempts to see if the command exists in a package that is not currently installed, and producing a more informative error message for that case. But to make the check, you must have all the configured package repositories accessible - including having their GPG keys available. And if there are problems, the standard error message is replaced with an even more cryptic one. – telcoM Jul 04 '20 at 20:03
  • @telcoM thaks I'll have a look at it. But I've never heard of `PackageKit-command-not-found` and I don't think I have installed it deliberately. Is it part of the default centos 8 installation? – user13267 Jul 05 '20 at 05:01
  • My test VMs are stripped-down "minimal" installations because that's what we tend to use as a base for servers at work; but I think Ubuntu included it in their default installation a few major releases ago, and RHEL/CentOS may have done the same. – telcoM Jul 09 '20 at 07:59

2 Answers2

7

TelcoM's comment answers the root cause of this:

Apparently you have the PackageKit-command-not-found RPM package installed. It adds a special customization to the shell's "command not found" error handler, which attempts to see if the command exists in a package that is not currently installed, and producing a more informative error message for that case.

But to make the check, you must have all the configured package repositories accessible - including having their GPG keys available. And if there are problems, the standard error message is replaced with an even more cryptic one.

As per Laurentino's answer this was a simple matter of downloading the correct gpg key for repo mariadb-main and moving to directory /etc/pki/rpm-gpg/:

wget https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

Other repos will have different keys and an exhaustive list of links can't reasonably be provided here.

Glorfindel
  • 805
  • 2
  • 10
  • 19
Philip Couling
  • 17,591
  • 5
  • 42
  • 82
2

For me the solutions was to do manually

sudo wget https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

directly inside of directory /etc/pki/rpm-gpg/, and that created the file RPM-GPG-KEY-MariaDB.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Laurentino
  • 36
  • 2