When I first installed mongodb on wsl2 it went all right except for the service. Then, when I completely uninstalled mongodb to install that again, I found some troubles in installing it.
In fact, after doing the command suggested by the guide:
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
--dearmor
Then I created the list file with
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
But when I apt update it throws those errors:
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:2 https://deb.nodesource.com/node_22.x nodistro InRelease
Hit:3 http://archive.ubuntu.com/ubuntu noble InRelease
Get:4 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Ign:5 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 InRelease
Hit:6 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 InRelease
Hit:7 https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 InRelease
Hit:8 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Get:9 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 Release [3457 B]
Get:10 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 Release.gpg [801 B]
Get:11 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1057 kB]
Get:12 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1060 kB]
Ign:10 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 Release.gpg
Reading package lists... Done
W: GPG error: https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 68818C72E52529D4
E: The repository 'https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
If i look with apt-key the keys I see that the key exists and it is valid.
-------------------------------------------------------------------------------------------
pub rsa4096 2022-02-23 [SC] [expires: 2027-02-22]
**** **** **** **** **** **** **** ****
uid [ unknown] MongoDB 6.0 Release Signing Key <packaging@mongodb.com>
/etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg
I've tried several ways to sign it but I can't solve it. Can someone help me?