diff --git a/Knot.files b/Knot.files
index 38fcd5a77724ebf1517ad57844614e4280db1df6..c7cbeeb34694afb9b668f4596de46d36d1316ff1 100644
--- a/Knot.files
+++ b/Knot.files
@@ -60,11 +60,6 @@ src/contrib/libbpf/include/uapi/linux/btf.h
 src/contrib/libbpf/include/uapi/linux/if_link.h
 src/contrib/libbpf/include/uapi/linux/if_xdp.h
 src/contrib/libbpf/include/uapi/linux/netlink.h
-src/contrib/lmdb/lmdb.h
-src/contrib/lmdb/mdb.c
-src/contrib/lmdb/midl.c
-src/contrib/lmdb/midl.h
-src/contrib/lmdb/mute_warnings.h
 src/contrib/macros.h
 src/contrib/mempattern.c
 src/contrib/mempattern.h
diff --git a/README b/README
index 694701a0fe5f051de3bfaa889d0e815e29f93240..1a1fa64e9e0ddbed03f0c774aaf3557c1ee8a7f7 100644
--- a/README
+++ b/README
@@ -18,10 +18,7 @@ $ sudo apt-get upgrade
 
 Install prerequisites:
 $ sudo apt-get install \
-  libtool autoconf make pkg-config liburcu-dev libgnutls28-dev libedit-dev
-
-Install optional packages to override embedded libraries:
-$ sudo apt-get install liblmdb-dev
+  libtool autoconf make pkg-config liburcu-dev libgnutls28-dev libedit-dev liblmdb-dev
 
 Install optional packages:
 $ sudo apt-get install \
@@ -37,10 +34,7 @@ Install basic development tools:
 
 Install prerequisites:
 # dnf install \
-  libtool autoconf pkgconfig automake userspace-rcu-devel gnutls-devel libedit-devel
-
-Install optional packages to override embedded libraries:
-# dnf install lmdb-devel
+  libtool autoconf pkgconfig automake userspace-rcu-devel gnutls-devel libedit-devel lmdb-devel
 
 Install optional packages:
 # dnf install \
diff --git a/configure.ac b/configure.ac
index 4b6fc49c07dd71383cfe754307ea95ad26802189..953969956d2150dc1217126d69fb291dec7f9af3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -437,80 +437,46 @@ AS_CASE([$enable_maxminddb],
 AS_IF([test "$enable_maxminddb" = yes], [AC_DEFINE([HAVE_MAXMINDDB], [1], [Define to 1 to enable MaxMind DB.])])
 AM_CONDITIONAL([HAVE_MAXMINDDB], [test "$enable_maxminddb" = yes])
 
-dnl Check for LMDB
-lmdb_MIN_VERSION_MAJOR=0
-lmdb_MIN_VERSION_MINOR=9
-lmdb_MIN_VERSION_PATCH=15
-lmdb_MIN_VERSION_STRING="$lmdb_MIN_VERSION_MAJOR.$lmdb_MIN_VERSION_MINOR.$lmdb_MIN_VERSION_PATCH"
-lmdb_MIN_VERSION_FULL="$((($lmdb_MIN_VERSION_MAJOR << 24) | ($lmdb_MIN_VERSION_MINOR << 16) | $lmdb_MIN_VERSION_PATCH))"
 AC_ARG_WITH([lmdb],
-    AC_HELP_STRING([--with-lmdb=[DIR]], [Link with external LMDB (>= $lmdb_MIN_VERSION_STRING)]),[
-    with_lmdb=$withval
-    ],[
-    with_lmdb=auto
-    ])
-
-have_lmdb=no
+  [AC_HELP_STRING([--with-lmdb=DIR], [explicit location where to find LMDB])]
+)
+PKG_CHECK_MODULES([lmdb], [lmdb >= 0.9.15], [], [
+  save_CPPFLAGS=$CPPFLAGS
+  save_LIBS=$LIBS
 
-AS_IF([test "$with_lmdb" != "no"],[
-    save_CPPFLAGS=$CPPFLAGS
-    save_LIBS=$LIBS
+  have_lmdb=no
 
-    # Look for lmdb in given path and common locations
-    for try_lmdb in "$with_lmdb" "" "/usr/local"; do
+  for try_lmdb in "$with_lmdb" "" "/usr/local" "/usr/pkg"; do
+    AS_IF([test -d "$try_lmdb"], [
+      lmdb_CFLAGS="-I$try_lmdb/include"
+      lmdb_LIBS="-L$try_lmdb/lib"
+    ],[
+      lmdb_CFLAGS=""
+      lmdb_LIBS=""
+    ])
 
-      AS_IF([test -d "$try_lmdb"], [
-        lmdb_CFLAGS="-I$try_lmdb/include"
-        lmdb_LIBS="-L$try_lmdb/lib"
-        ],[
-        lmdb_CFLAGS=""
-        lmdb_LIBS=""
-        ])
+    CPPFLAGS="$save_CPPFLAGS $lmdb_CFLAGS"
+    LIBS="$save_LIBS $lmdb_LIBS"
 
-      CPPFLAGS="$save_CPPFLAGS $lmdb_CFLAGS"
-      LIBS="$save_LIBS $lmdb_LIBS"
-
-      AC_SEARCH_LIBS([mdb_env_open], [lmdb], [
-          AC_CHECK_HEADERS([lmdb.h], [], [
-              AC_MSG_ERROR([lmdb headers not found in `$try_lmdb', is your installation complete?])])
-          AC_COMPUTE_INT(lmdb_VERSION_FULL, MDB_VERSION_FULL, [#include <lmdb.h>],
-              AC_MSG_ERROR([Unable to determine lmdb version from MDB_VERSION_FULL]))
-          AS_IF([test "$lmdb_VERSION_FULL" -ge "$lmdb_MIN_VERSION_FULL"],[
-              lmdb_LIBS="$lmdb_LIBS -llmdb"
-              have_lmdb=yes],[
-              unset lmdb_CFLAGS
-              unset lmdb_LIBS
-              AC_MSG_WARN([lmdb version 0.9.15 and higher not found, using embedded version])
-              ])
-          break
-          ])
-
-      unset lmdb_CFLAGS
-      unset lmdb_LIBS
-      # do not cache result of AC_SEARCH_LIBS test
-      unset ac_cv_search_mdb_env_open
-    done
+    AC_SEARCH_LIBS([mdb_txn_id], [lmdb], [
+      have_lmdb=yes
+      lmdb_LIBS="$lmdb_LIBS -llmdb"
+      AC_SUBST([lmdb_CFLAGS])
+      AC_SUBST([lmdb_LIBS])
+      break
+    ])
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LIBS="$save_LIBS"
+    # do not cache result of AC_SEARCH_LIBS test
+    unset ac_cv_search_mdb_txn_id
+  done
 
-    # fail the configure if we haven't found lmdb library in the system
-    AS_IF([test "$with_lmdb" != "auto" -a "$have_lmdb" = "no"],[
-        AC_MSG_ERROR([shared lmdb library not found])
-        ])
-    ])
+  CPPFLAGS="$save_CPPFLAGS"
+  LIBS="$save_LIBS"
 
-AS_IF([test "$have_lmdb" != "no"],[
-    AC_SUBST([lmdb_LIBS])
-    enable_lmdb=shared
-    external_lmdb_LIBS=$lmdb_LIBS
-    ],[
-    enable_lmdb=embedded
-    lmdb_CFLAGS="-I\$(top_srcdir)/src/contrib/lmdb"
-    ])
-AM_CONDITIONAL([HAVE_LMDB], test "$enable_lmdb" = "shared")
-AC_SUBST([lmdb_CFLAGS])
-AC_SUBST([external_lmdb_LIBS])
+  AS_IF([test "$have_lmdb" = "no"], [
+    AC_MSG_ERROR([lmdb library not found])
+  ])
+])
 
 # LMDB mapping sizes
 conf_mapsize_default=500
@@ -726,7 +692,7 @@ result_msg_base="  Knot DNS $VERSION
     LibURCU:  ${liburcu_LIBS} ${liburcu_CFLAGS}
     GnuTLS:   ${gnutls_LIBS} ${gnutls_CFLAGS}
     Libedit:  ${libedit_LIBS} ${libedit_CFLAGS}
-    LMDB:     ${enable_lmdb} ${lmdb_LIBS} ${lmdb_CFLAGS}
+    LMDB:     ${lmdb_LIBS} ${lmdb_CFLAGS}
     Config:   ${conf_mapsize} MiB default mapsize
 
     Prefix:      ${knot_prefix}
diff --git a/distro/deb/copyright b/distro/deb/copyright
index 34823bafd34b922cc2f615a6f77ff0d694c11969..108c28c2c4413d8763a4c34c61f5d50048633b47 100644
--- a/distro/deb/copyright
+++ b/distro/deb/copyright
@@ -47,11 +47,6 @@ Copyright: 2013-2015 Alexei Starovoitov <ast@kernel.org>
            2018-2019 Facebook
 License: LGPL-2.1
 
-Files: src/contrib/lmdb/lmdb.h src/contrib/lmdb/mdb.c src/contrib/lmdb/midl.*
-Copyright: 2000-2018 The OpenLDAP Foundation
-           2001-2018 Howard Chu, Symas Corp.
-License: OLDAP-2.8
-
 Files: src/contrib/openbsd/siphash.*
 Copyright: 2013 Andre Oppermann <andre@FreeBSD.org>
 License: BSD-3-Clause
@@ -134,52 +129,6 @@ License: LGPL-2.1
  On Debian systems, the complete text of the GNU Lesser General Public
  License version 2.1 can be found in `/usr/share/common-licenses/LGPL-2.1'.
 
-License: OLDAP-2.8
- Redistribution and use of this software and associated documenta-
- tion ("Software"), with or without  modification,  are  permitted
- provided that the following conditions are met:
- .
- 1.  Redistributions  in  source form must retain copyright statements
-    and notices,
- .
- 2. Redistributions in binary form must reproduce applicable copyright
-    statements  and notices, this list of conditions, and the following
-    disclaimer in the documentation and/or other materials provided
-   with the distribution, and
- .
- 3. Redistributions must contain a verbatim copy of this document.
- .
- The  OpenLDAP  Foundation  may  revise  this license from time to
- time.  Each revision is distinguished by a version  number.   You
- may use this Software under terms of this license revision or un-
- der the terms of any subsequent revision of the license.
- .
- THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS CON-
- TRIBUTORS  ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, IN-
- CLUDING, BUT NOT LIMITED  TO,  THE  IMPLIED  WARRANTIES  OF  MER-
- CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE OPENLDAP FOUNDATION, ITS  CONTRIBUTORS,  OR
- THE  AUTHOR(S)  OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DI-
- RECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS IN-
- TERRUPTION)  HOWEVER  CAUSED  AND  ON  ANY  THEORY  OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING  NEGLI-
- GENCE  OR  OTHERWISE)  ARISING  IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- .
- The names of the authors and copyright holders must not  be  used
- in  advertising  or  otherwise  to promote the sale, use or other
- dealing in this Software without specific, written prior  permis-
- sion.  Title to copyright in this Software shall at all times re-
- main with copyright holders.
- .
- OpenLDAP is a registered trademark of the OpenLDAP Foundation.
- .
- Copyright 1999-2003 The OpenLDAP Foundation, Redwood City,  Cali-
- fornia,  USA.   All Rights Reserved.  Permission to copy and dis-
- tribute verbatim copies of this document is granted.
-
 License: 0BSD
  Permission to use, copy, modify, and distribute this software for any
  purpose with or without fee is hereby granted, provided that the above
diff --git a/src/contrib/Makefile.inc b/src/contrib/Makefile.inc
index fc4221ecda6f5dc811a8abf6734288363556b5d1..02a3f8bd93c8b8f98569fae587659f5dc5d30a68 100644
--- a/src/contrib/Makefile.inc
+++ b/src/contrib/Makefile.inc
@@ -3,9 +3,6 @@ noinst_LTLIBRARIES += libcontrib.la
 libcontrib_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY)
 libcontrib_la_LDFLAGS  = $(AM_LDFLAGS) $(LDFLAG_EXCLUDE_LIBS)
 libcontrib_la_LIBADD   = $(pthread_LIBS)
-if !HAVE_LMDB
-libcontrib_la_CPPFLAGS += -include contrib/lmdb/mute_warnings.h
-endif !HAVE_LMDB
 if USE_GNUTLS_MEMSET
 libcontrib_la_CPPFLAGS += $(gnutls_CFLAGS)
 libcontrib_la_LIBADD   += $(gnutls_LIBS)
@@ -20,9 +17,7 @@ EXTRA_DIST += \
 	contrib/licenses/BSD-3-Clause		\
 	contrib/licenses/LGPL-2.0		\
 	contrib/licenses/LGPL-2.1		\
-	contrib/licenses/OLDAP-2.8		\
 	contrib/libbpf/LICENSE			\
-	contrib/lmdb/LICENSE			\
 	contrib/openbsd/LICENSE			\
 	contrib/ucw/LICENSE			\
 	contrib/dnstap/dnstap.proto
diff --git a/src/contrib/licenses/OLDAP-2.8 b/src/contrib/licenses/OLDAP-2.8
deleted file mode 100644
index 05ad7571e448b9d83ead5d4691274d9484574714..0000000000000000000000000000000000000000
--- a/src/contrib/licenses/OLDAP-2.8
+++ /dev/null
@@ -1,47 +0,0 @@
-The OpenLDAP Public License
-  Version 2.8, 17 August 2003
-
-Redistribution and use of this software and associated documentation
-("Software"), with or without modification, are permitted provided
-that the following conditions are met:
-
-1. Redistributions in source form must retain copyright statements
-   and notices,
-
-2. Redistributions in binary form must reproduce applicable copyright
-   statements and notices, this list of conditions, and the following
-   disclaimer in the documentation and/or other materials provided
-   with the distribution, and
-
-3. Redistributions must contain a verbatim copy of this document.
-
-The OpenLDAP Foundation may revise this license from time to time.
-Each revision is distinguished by a version number.  You may use
-this Software under terms of this license revision or under the
-terms of any subsequent revision of the license.
-
-THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS
-CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT
-SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S)
-OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-The names of the authors and copyright holders must not be used in
-advertising or otherwise to promote the sale, use or other dealing
-in this Software without specific, written prior permission.  Title
-to copyright in this Software shall at all times remain with copyright
-holders.
-
-OpenLDAP is a registered trademark of the OpenLDAP Foundation.
-
-Copyright 1999-2003 The OpenLDAP Foundation, Redwood City,
-California, USA.  All Rights Reserved.  Permission to copy and
-distribute verbatim copies of this document is granted.
diff --git a/src/libknot.pc.in b/src/libknot.pc.in
index b723b24ee2b00e04f51c5ea712e127eeb8a1ec86..9ce780237b5773cbfe846b82363fa6453c40c34d 100644
--- a/src/libknot.pc.in
+++ b/src/libknot.pc.in
@@ -10,5 +10,5 @@ URL: https://www.knot-dns.cz
 Version: @PACKAGE_VERSION@
 Requires.private: libdnssec = @PACKAGE_VERSION@
 Libs: -L${libdir} -lknot
-Libs.private: -lm @external_lmdb_LIBS@
+Libs.private: -lm @lmdb_LIBS@
 Cflags: -I${includedir}