I am running a server which hosts both a MySQL instance (with several databases) and some SQLite files. I would like to use Adminer to manage all of them, provided that valid credentials are given by the users. Also, a list of databases should be populated.
In case of MySQL, valid database users can be used and the connection works out of the box. However, SQLite support must be added explicitly. Adminer gives this error:
Implement login() method to use SQLite.
Adminer
class to enable SQLite login?How to Access Adminer. To access it, all you need to do is visit its link through your browser. For example, if you've placed it in your website's root directory, then you can access it by visiting https://your-website.com/adminer-4.7.8.php.
Adminer (formerly phpMinAdmin) is a full-featured database management tool written in PHP. Conversely to phpMyAdmin, it consist of a single file ready to deploy to the target server. Adminer is available for MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Elasticsearch, MongoDB and others via plugin.
SQLite database files have a maximum size of about 140 TB. On a phone, the size of the storage (a few GB) will limit your database file size, while the memory size will limit how much data you can retrieve from a query. Furthermore, Android cursors have a limit of 1 MB for the results.
The connection is made by specifying the "server file system" path of an existing database. Ce plug-in pour l'application Web Adminer permet de se « connecter à un serveur de bases de données SQLite3 » sans avoir besoin de fournir d'informations d'identification ( no credentials: no username and no password ).
To use it, all you have to do is upload its single PHP file, point your browser towards it, and log in. Unlike phpMyAdmin, which only supports the management of MySQL and MariaDB databases, Adminer also supports managing other databases such as PostgreSQL, SQLite, MS SQL, Oracle, SimpleDB, Elasticsearch, MongoDB, and Firebird.
After logging in to Adminer, you can explore your WordPress site’s database with it. I recommend you to remove the Adminer file from your server once you’ve finished using it. Leaving it unattended on your server for an extended period may expose your database to vulnerabilities.
Adminer’s plug-and-play design also means that you can delete it from your server quickly when it’s not needed anymore. If you want to use it again in the future, you can upload it back quickly. You cannot do the same with phpMyAdmin. By using Adminer’s login-ssl plugin, you can connect to your MySQL database server using SSL.
This answer applies to Adminer version 4.2.5. Unfortunately, it is not valid for Adminer 4.3.x.
You need to override the login
and databases
methods of the Adminer
class, making sure you do it only for the SQLite driver, not in other cases. The following code achieves a basic login system with a list of databases:
<?php
function adminer_object() {
class AdminerSoftware extends Adminer {
function login($login, $password) {
global $jush;
if ($jush == "sqlite")
return ($login === 'admin') && ($password === 'changeme');
return true;
}
function databases($flush = true) {
if (isset($_GET['sqlite']))
return ["/path/to/first.db", "/path/to/second.db"];
return get_databases($flush);
}
}
return new AdminerSoftware;
}
include "./adminer-4.2.5.php";
The code could be adapted to support multiple users. Save the file as index.php
in the same directory where adminer-4.2.5.php
is located. Make sure to tweak the username, password and paths to the databases.
Here are some important remarks:
login
method is not properly named, it is an initial check performed by Adminertrue
like the original class does
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With