Install MyWebSQL on Ubuntu 20.04
Introduction
MyWebSQL is an open-source, web-based database client for managing database servers and written in PHP. It supports managing MySQL, PostgreSQL, and SQLite databases. Some of its features are:
- Multiple syntax highlighted SQL editors.
- WYSIWYG table creator/editor.
- Multilingual interface with themes support.
- Importing and exporting database scripts, tables, or results to multiple formats.
- Multitasking environment.
This article describes how to install MyWebSQL on Ubuntu 20.04 server.
Prerequisites
- Deploy a fully updated Vultr Ubuntu 20.04 Server.
- Create a non-root user with sudo access.
1. Install Required Packages
SSH to your server as a non-root user with sudo access.
Update the system package list to update all packages to the latest available versions.
$ sudo apt update
Install PHP 7.4 and more modules.
$ sudo apt install apache2 php7.4 libapache2-mod-php7.4 php7.4-json php7.4-common php7.4-gmp php7.4-curl php7.4-mysql php7.4-pgsql php7.4-sqlite3 php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-cli php7.4-bcmath php7.4-xml php7.4-zip php7.4-imap wget unzip -y
2. Install Database Server
Install a database server for demonstration purposes in this article. Choose either MySQL or PostgreSQL.
MySQL Server
Install MySQL database server.
$ sudo apt install mysql-server -y
Secure your MySQL installation.
$ sudo mysql_secure_installation
When prompted, answer the questions as shown below:
- Setup VALIDATE PASSWORD plugin? Press N, then Enter.
- Remove anonymous users? Press Y, then Enter.
- Disallow root login remotely? Press Y, then Enter.
- Remove test database and access to it? Press Y, then Enter.
- Reload privilege tables now? Press Y, then Enter.
Enable the database server to start automatically on a reboot.
$ sudo systemctl enable mysql
Log in to MySQL shell. At the password prompt, just press Enter to continue.
$ sudo mysql -u root -p
Create a database called
websql
.CREATE DATABASE websql;
Create a database user called
websqluser
with a passwordStrongPassword
.CREATE USER 'websqluser'@'localhost' IDENTIFIED BY 'StrongPassword';
Grant the user full access to the database.
GRANT ALL ON websql.* TO 'websqluser'@'localhost' WITH GRANT OPTION;
Save the changes made to the database.
FLUSH PRIVILEGES;
Exit MySQL shell.
exit;
PostgreSQL Server
Install PostgreSQL database server.
$ sudo apt install postgresql-12 -y
Enable the database server to start automatically on a reboot.
$ sudo systemctl enable postgresql
Start the database server.
$ sudo systemctl start postgresql
Secure PostgreSQL by changing the default PostgreSQL password.
$ sudo passwd postgres
Switch to the
postgres
user.$ su - postgres
Create a new database user named
websqluser
.$ createuser websqluser
Log in to the PostgreSQL instance.
$ psql
Set a secure password
StrongPassword
for the user.ALTER USER websqluser WITH ENCRYPTED password 'StrongPassword';
Create a database named
websql
and set the owner towebsqluser
.CREATE DATABASE websql OWNER websqluser;
Grant all the privileges on the database to the user.
GRANT ALL PRIVILEGES ON DATABASE websql to websqluser;
Exit PostgreSQL instance.
\q
Return to your non-root sudo user account.
$ exit
3. Install MyWebSQL
Download the MyWebSQL package. To find the latest version of this software, visit the download page.
$ wget https://liquidtelecom.dl.sourceforge.net/project/mywebsql/stable/mywebsql-3.8.zip -O mywebsql-3.8.zip
Extract the downloaded archive.
$ sudo unzip mywebsql-3.8.zip
Create the installation directory
/var/www/html/mywebsql
.$ sudo mkdir /var/www/html/mywebsql/
Move the extracted files to the installation directory.
$ sudo mv mywebsql/* /var/www/html/mywebsql
Change ownership of the installation directory.
$ sudo chown -R www-data:www-data /var/www/html/mywebsql/
Change access permissions for the directory.
$ sudo chmod -R 755 /var/www/html/mywebsql/
4. Configure Apache2
Create a new Apache virtual host file named
mywebsql.conf
.$ sudo nano /etc/apache2/sites-available/mywebsql.conf
Add the following content to the file. Then, save and close the file.
<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/mywebsql ServerName example.com <Directory /var/www/html/mywebsql> Options FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/example.com_error.log CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined </VirtualHost>
Disable Apache default configuration file.
$ sudo a2dissite 000-default.conf
Enable MyWebSQL Apache configuration file.
$ sudo a2ensite mywebsql.conf
Enable Apache rewrite mode.
$ sudo a2enmod rewrite
Restart Apache service.
$ sudo systemctl restart apache2
5. Access MyWebSQL Web Interface
Check the installation status of MyWebSQL. Go to your browser and visit http://Server_IP/install.php
. For example:
http://192.0.2.11/install.php
If the environment passes all the requirements, remove the installation file named install.php
to avoid security breaches.
$ sudo rm /var/www/html/mywebsql/install.php
Access the MyWebSQL Web Interface, go to your browser, and visit http://Server_IP/
. For example:
http://192.0.2.10
Conclusion
You have installed MyWebSQL on your server. For both MySQL and PostgreSQL servers, use websqluser as the User ID and StrongPassword as the Password. Select the corresponding database server, your preferred language, and then log in to the dashboard.
More Information
To learn more about using MyWebSQL, go to the official documentation page.