How To Install MariaDB Server + phpMyAdmin on Entware

0 -  Flash RMerlin firmware from here

1 - Install Entware-NG from here and choose to create a 2Gb swap file

2 - Install lighttpd web server and php7 from here

3 - Install MariaDb server

opkg install mariadb-server mariadb-server-extra mariadb-client mariadb-client-extra \
php7-mod-mysqli php7-mod-mbstring php7-mod-json php7-mod-session php7-mod-ctype

4 - Restart lighttpd webserver

/opt/etc/init.d/S80lighttpd restart

5 - For initial setup, find and replace MariaDB user with your router username in /opt/etc/mysql/conf.d/50-server.cnf

grep -oE -m1 '^[^:]+' /etc/passwd
sed -i "/^user\t\t=/c\user\t\t= $(grep -oE -m1 '^[^:]+' /etc/passwd)" \
/opt/etc/mysql/conf.d/50-server.cnf

6 - Initialize MariaDB data directory

mysql_install_db --force

7 -  Start MariaDB server

/opt/etc/init.d/S70mysqld restart

8 - Secure server and create password for root

/opt/bin/mysql_secure_installation -u admin

RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
/opt/bin/mysql_secure_installation: line 416: stty: not found
Enter current password for root (enter for none): ENTER
/opt/bin/mysql_secure_installation: line 416: stty: not found
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
ou already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
/opt/bin/mysql_secure_installation: line 479: stty: not found
New password: password
Re-enter new password: password
/opt/bin/mysql_secure_installation: line 479: stty: not found
Password updated successfully!Reloading privilege tables..
... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!

9 - Login to mysql

mysql -u root -p

10  - Create your first database

mysql> create database some_db_name;
mysql> grant all privileges on some_db_name.* to some_user_name@localhost identified by 'some_user_pass';
mysql> quit

11 - Download phpMyAdmin, version 5.0.2 in the moment of creating this tutorial

cd /opt/share/www/
wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip --no-check-certificate
unzip ./phpMyAdmin-5.0.2-all-languages.zip
mv ./phpMyAdmin-5.0.2-all-languages ./phpmyadmin
rm ./phpMyAdmin-5.0.2-all-languages.zip

12 - Fix phpmyadmin configuration file

cp /opt/share/www/phpmyadmin/config.sample.inc.php /opt/share/www/phpmyadmin/config.inc.php
chmod 644 /opt/share/www/phpmyadmin/config.inc.php
sed -i 's/localhost/127.0.0.1/g' "/opt/share/www/phpmyadmin/config.inc.php"

13 - Go to your router ip address and port 81/phpmyadmin or www.asusrouter.com:81/phpmyadmin

phpmyadmin1

14 - Login with root and password created on step 8 for all databases or credential created on step 10 for only one database

Now you are ready to make changes on desired databases