Databases – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Fri, 06 Jan 2023 07:46:15 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How To Install MySQL 8 on Amazon Linux 2 https://tecadmin.net/how-to-install-mysql-8-on-amazon-linux-2/ https://tecadmin.net/how-to-install-mysql-8-on-amazon-linux-2/#respond Tue, 06 Sep 2022 01:39:49 +0000 https://tecadmin.net/?p=31241 MySQL is a very popular open-source relational database management system that can run on Linux, Windows, and Mac OS. It’s typically used as the back-end database for web applications, though it can also be used to store data for other software. You can use MySQL to store and organize data, retrieve it when needed, and [...]

The post How To Install MySQL 8 on Amazon Linux 2 appeared first on TecAdmin.

]]>
MySQL is a very popular open-source relational database management system that can run on Linux, Windows, and Mac OS. It’s typically used as the back-end database for web applications, though it can also be used to store data for other software. You can use MySQL to store and organize data, retrieve it when needed, and transform it into a different format (e.g. changing it from text to numbers). It’s commonly used by companies of all sizes as the database for their websites and applications.

This article will walk through the process of installing MySQL 8 on Amazon Linux 2. When you’re finished, you’ll have a fully-functioning MySQL database that you can use with either the AWS Console or your own application. You can also use Amazon RDS to configure other databases besides MySQL.

How to Install MySQL 8 on Amazon Linux

The MySQL official team provides the RPM packages for the installation of Amazon Linux systems. Follow the below steps one by one to complete the MySQL installation.

  1. Configure Yum Repository
  2. Most of the packages required the dependencies that are available in other third-party repositories. Use the following command to configure the EPEL repository that is required for package installation.

    sudo amazon-linux-extras install epel -y 
    

    Then configure the MySQL repository by installing the package provided by the MySQL official site.

    sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm 
    

  3. Install MySQL Server
  4. You can successfully configure the repositories, your system is ready for MySQL installation. Execute the below-mentioned command to install MySQL 8 community server on Amazon Linux.

    sudo yum install mysql-community-server 
    

    Press ‘y’ for the confirmation prompted during the installation.

    How to Install MySQL 8 on Amazon Linux 2
    MySQL pacakges installation on Amazon Linux 2

  5. Activate and Start MySQL Service
  6. Once the installation is successfully finished. The default MySQL service will be stopped and in an inactive state. First, use the following commands to activate the service to auto-start on system startup, then start it manually for the first time.

    systemctl active mysqld 
    systemctl start mysqld 
    

    Then, use the following command to view the MySQL service status. It should be active and running.

    systemctl status mysqld 
    
    How to Install MySQL 8 on Amazon Linux 2
    Activate and start MySQL service

  7. Find initial root password
  8. During the installation of packages, an initial password is configured for the MySQL root account. You can find this password from the MySQL log file.

    cat /var/log/mysql.log | grep "A temporary password" 
    

    You will see the output below that includes the default root password.

    How to Install MySQL 8 on Amazon Linux 2
    Getting the default root password after installation

    This password will be required in the next step.

  9. MySQL Post Installation Setup
  10. A post-installation script is provided by the MySQL packages. That is helpful for configuring MySQL once after the installation. This helps us to configure a strong root account password, remote anonymous users, disallow root access remotely and remove the test database.

    Execute the following command from the terminal:

    sudo mysql_secure_installation 
    

    Enter the root password found in the above step, then set a new password for the MySQL root account. Next, follow the onscreen instructions and Press Y for all other operations to apply improved security.

    • Enter password for user root: [Enter current root password]
    • New password: [Enter a new root password]
    • Re-enter new password: [Re-Enter the new root password]
    • Estimated strength of the password: 100
      Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
    • Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    • Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    • Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    • Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    • All done!

  11. Connect to MySQL
  12. Your MySQL server is ready to use now. From the terminal, you can run the below command to connect to the MySQL command line interface. It will prompt for the root account password. On successful authentication, you will get the MySQL prompt.

    mysql -u root -p 
    

    Enter the MySQL root user password:

    Output:
    Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 8.0.30 MySQL Community Server - GPL Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

    Here you can create databases, tables, users, and all the required things by using the structured query language statements.

Next Steps for Maintaining MySQL

As you’re setting up your new database, it’s a good idea to put some thought into how you will maintain the database in the long term. This guide focuses on setting up a new database, but you should also consider ways to make your database more automated and easier to manage. One simple way to do this is to automate the process of backing up your database. This will allow you to keep a copy of your data in case something goes wrong and you need to restore it from a previous point in time. This can be done with the help of some simple scripts that call the MySQL database and write the data to a different location.

We already have created a simple database backup script and one advance MySQL database backup script for the purpose. You can use these scripts to quickly configure the database backups.

Final Words

There are many reasons why you might want to run your database on Amazon’s cloud. Some common ones have cost, ease of setup and maintenance, and the ability to scale up or down as needed. Running your database on Amazon Linux has a few advantages over using a different Linux distribution. Amazon has thoroughly tested its distribution and it is optimized for running on its cloud infrastructure. When you’re setting up a new database, it’s important to choose a solution that meets your needs and can grow with your business.

This guide focuses on installing MySQL on Amazon Linux, which is one of the easiest and most cost-effective ways to get a new database up and running.

The post How To Install MySQL 8 on Amazon Linux 2 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-mysql-8-on-amazon-linux-2/feed/ 0
(Resolved) Unknown collation: utf8mb4_unicode_520_ci https://tecadmin.net/resolved-unknown-collation-utf8mb4_unicode_520_ci/ https://tecadmin.net/resolved-unknown-collation-utf8mb4_unicode_520_ci/#respond Sat, 30 Jul 2022 22:44:02 +0000 https://tecadmin.net/?p=30851 A collation is a set of rules that defines how to compare and sort character strings in a database server. In this tutorial, we are discussing an error faced during database restoration on another server. Let’s see the problem and solution to the issue faced recently: The Problem: During the migration of a WordPress application, [...]

The post (Resolved) Unknown collation: utf8mb4_unicode_520_ci appeared first on TecAdmin.

]]>
A collation is a set of rules that defines how to compare and sort character strings in a database server. In this tutorial, we are discussing an error faced during database restoration on another server.

Let’s see the problem and solution to the issue faced recently:

The Problem:

During the migration of a WordPress application, I faced the following error with the restoration of the MySQL database. The collation id may differ based on the MySQL version.

Error message:

Error 1273 (HY000) at line 36 Unknown collation: 'utf8mb4_unicode_520_ci'

Here you go with a solution.

The Solution:

After searching for the error, I found that the MySQL server running on the other server is an older version than the source. So we find out that the destination server doesn’t support the ‘utf8mb4_unicode_520_ci’ collation.

To resolve this issue, I did a little change in the backup file. Edit the database backup file in text editor and replace all occurrences of “utf8mb4_unicode_520_ci” with “utf8mb4_general_ci“. Also, if you found “CHARSET=utf8mb4“, replace this with “CHARSET=utf8“.

Replace the below string:

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

with:

ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

Save the backup file and restore the database.

The Linux system users can use the sed command to replace text in files directly.

sed -i 's/utf8mb4_unicode_520_ci/utf8_general_ci/g' backup.sql  
sed -i 's/CHARSET=utf8mb4/CHARSET=utf8/g' backup.sql  

That’s it, Now the database is successfully restored without any errors!

Hopefully, this is solution helped you to resolve “Unknown collation: ‘utf8mb4_unicode_520_ci’” issue with MySQL databases.

The post (Resolved) Unknown collation: utf8mb4_unicode_520_ci appeared first on TecAdmin.

]]>
https://tecadmin.net/resolved-unknown-collation-utf8mb4_unicode_520_ci/feed/ 0
How To Install phpMyAdmin on Ubuntu 22.04 https://tecadmin.net/how-to-install-phpmyadmin-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-phpmyadmin-on-ubuntu-22-04/#comments Thu, 21 Jul 2022 08:49:47 +0000 https://tecadmin.net/?p=30615 You can use phpMyAdmin to manage your MySQL databases on a VPS. It’s an excellent tool for browsing, editing, creating, and dropping tables, as well as modifying columns and data. You don’t need to SSH into remote machines or load up some new terminal window to execute a few SQL queries every time you want [...]

The post How To Install phpMyAdmin on Ubuntu 22.04 appeared first on TecAdmin.

]]>
You can use phpMyAdmin to manage your MySQL databases on a VPS. It’s an excellent tool for browsing, editing, creating, and dropping tables, as well as modifying columns and data. You don’t need to SSH into remote machines or load up some new terminal window to execute a few SQL queries every time you want to run some database queries. Instead, you can use a program like phpMyAdmin and keep everything in one place.

This blog will show you how to install and set up phpMyAdmin on Ubuntu 22.04 server.

Step 1 – Install Apache and PHP

We are assuming you already have installed the MySQL server on Ubuntu system. So just install the other required packages to run and access phpMyAdmin.

sudo apt install apache2 wget unzip 
sudo apt install php php-zip php-json php-mbstring php-mysql 

Once the installation is finished, enable and start the Apache web server.

sudo systemctl enable apache2 
sudo systemctl start apache2 

Step 2 – Install phpMyAdmin on Ubuntu 22.04

You can quickly install the phpMyAdmin from the default Ubuntu repositories. But they contain an older version of phpMyAdmin. If you are okay with the old version simply type apt install phpmyadmin, but to install the latest version, you need to download it from the official website.

Your system is ready for the phpMyAdmin installation. Download the latest phpMyAdmin archive from the official download page, or use the below commands to download phpMyAdmin 5.2 on your system. Once the downloading is finished, extract the archive and move it to the proper location.

wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip 
unzip phpMyAdmin-5.2.0-all-languages.zip 
sudo mv phpMyAdmin-5.2.0-all-languages /usr/share/phpmyadmin 

Next, create tmp directory and set the proper permissions. This is a necessary step to make it work properly.

sudo mkdir /usr/share/phpmyadmin/tmp 
sudo chown -R www-data:www-data /usr/share/phpmyadmin 
sudo chmod 777 /usr/share/phpmyadmin/tmp 

Step 3 – Configure phpMyAdmin

Now, you need to configure the webserver to serve phpMyAdmin on the network. Create an Apache configuration file for phpMyAdmin and edit it in a text editor:

sudo vim /etc/apache2/conf-available/phpmyadmin.conf 

add the below content to the file.

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin/>
   AddDefaultCharset UTF-8
   <IfModule mod_authz_core.c>
      <RequireAny>
      Require all granted
     </RequireAny>
   </IfModule>
</Directory>

<Directory /usr/share/phpmyadmin/setup/>
   <IfModule mod_authz_core.c>
     <RequireAny>
       Require all granted
     </RequireAny>
   </IfModule>
</Directory>

Save your file. Press ESC key to switch to command more. Then type :wq (colon+w+q) and hit Enter button.

After making all the changes, make sure to start the Apache service to reload all settings.

sudo a2enconf phpmyadmin 
sudo systemctl restart apache2 

Step 4 – Adjusting FirewallD

The systems with enabled firewalls need to allow HTTP service from the firewall. Run the below commands to open a port for the webserver in the firewall.

sudo firewall-cmd --permanent --add-service=http 
sudo firewall-cmd --reload 

Step 5 – Create a MySQL Database and User

Connect to the MySQL server running on your system.

mysql 

Execute the following MySQL queries one by one to create a database and user. Also, assign the privileges to the user on the database.

mysql> CREATE DATABASE  tecadmin;
Query OK, 1 row affected (0.01 sec)

mysql> CREATE USER 'tecadmin'@'localhost' IDENTIFIED BY 'Pa$$w0rd';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL ON tecadmin.* TO 'tecadmin'@'localhost';
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Step 6 – Access phpMyAdmin

All done. You have finished the setup with the phpMyAdmin on the Ubuntu Linux system. Now access phpMyAdmin with the server IP address or domain name.

http://your-server-ip-domain/phpmyadmin

Replace your-server-ip-domain with the localhost (for the local machines), or system IP address for remote machines. I have updated our DNS and pointed dbhost.tecadmin.net to the server’s IP address.

How to Install phpMyAdmin on Ubuntu 22.04
phpMyAdmin Login Screen

Log in with the username and password used to access MySQL on the command line.

Installing phpMyAdmin on Ubuntu 22.04
phpMyAdmin Dashboard

Conclusion

You have successfully configured phpMyAdmin on the Ubuntu system. Also you can disable root user login for the for the security purposes in phpMyAdmin.

You can use phpMyAdmin to administer the MySQL server without login in through the command line.

The post How To Install phpMyAdmin on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-phpmyadmin-on-ubuntu-22-04/feed/ 4
How to Install MariaDB on Ubuntu 22.04 https://tecadmin.net/how-to-install-mariadb-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-mariadb-on-ubuntu-22-04/#comments Wed, 25 May 2022 09:51:16 +0000 https://tecadmin.net/?p=3982 MariaDB is a popular open-source relation database system developed by the original developer of the MySQL server. It is originally forked from the MySQL server with multiple enhancements. This tutorial will guide you with the installation of the MariaDB server on the Ubuntu 22.04 Linux system. 1. Configure Repository The MariaDB packages are available in [...]

The post How to Install MariaDB on Ubuntu 22.04 appeared first on TecAdmin.

]]>
MariaDB is a popular open-source relation database system developed by the original developer of the MySQL server. It is originally forked from the MySQL server with multiple enhancements.

This tutorial will guide you with the installation of the MariaDB server on the Ubuntu 22.04 Linux system.

1. Configure Repository

The MariaDB packages are available in default Ubuntu repositories. Also, MariaDB provides an official repository to install the latest version on Ubuntu systems.

In order to configure MariaDB Apt repository, open a terminal with a sudo privileged account and run the following commands.

sudo apt install software-properties-common dirmngr apt-transport-https 
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' 
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://atl.mirrors.knownhost.com/mariadb/repo/10.8/ubuntu jammy main' 

The above commands will create a repository file under /etc/apt/sources.list.d directory.

2. Installing MariaDB on Ubuntu

Next, execute the following commands to install the MariaDB server and client on your Ubuntu system.

sudo apt update 
sudo apt install mariadb-server 

Press ‘y’ and hit Enter, when prompted for the confirmation.

Installing MariaDB on Ubuntu
Installing MariaDB Server on Ubuntu

Once the installation is finished, execute the mysql_secure_installation script to secure MariaDB server and set a password for root account.

sudo sudo mysql_secure_installation 

Follow the on-screen instructions to complete the security wizard.

3. Manage MariaDB Service

MariaDB creates a systemd configuration file to manage its service. Use the following commands to stop, start, or restart the MariaDB service.

sudo systemctl start mariadb 
sudo systemctl stop mariadb 

To view the current status of MariaDB service, type:

sudo systemctl status mariadb 

4. Connect to MariaDB

You can get a MariaDB shell to create users, databases, and other related activities. To connect shell, type:

mysql -u root -p 

Type the MariaDB root user password you set with the mysql_secure_installation command.

Output:
Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 19 Server version: 10.8.3-MariaDB-2ubuntu1 Ubuntu 22.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>

Conclusion

This tutorial helped you to install and configure the MariaDB server on the Ubuntu system. Now you can create databases for your awesome applications. We strongly recommended creating a separate user account for the databases.

The post How to Install MariaDB on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-mariadb-on-ubuntu-22-04/feed/ 3
How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04 https://tecadmin.net/how-to-install-lemp-stack-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-lemp-stack-on-ubuntu-22-04/#comments Thu, 07 Apr 2022 01:31:43 +0000 https://tecadmin.net/?p=9770 The Linux operating system is a very popular and widely used OS for the server. It powers the majority of the world’s websites, including some of the most well-known ones such as Yahoo, Google, and Facebook. The logical acronym LAMP is commonly used to refer to the mixture of free and open-source software that is [...]

The post How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04 appeared first on TecAdmin.

]]>
The Linux operating system is a very popular and widely used OS for the server. It powers the majority of the world’s websites, including some of the most well-known ones such as Yahoo, Google, and Facebook. The logical acronym LAMP is commonly used to refer to the mixture of free and open-source software that is frequently used together to create a server architecture that can handle dynamic websites, such as those built on PHP, MySQL, and Apache.

Each letter in the acronym refers to a separate software package: That being said, let’s see how we can install and setup LEMP Stack on Ubuntu.

Pre-Requisities

Assuming that you have a running Ubuntu 22.04 Linux system with sudo (or root) privileged access.

Access your system and open a terminal. It will be good to update the package manager cache and upgrade currently installed packages. To do this execute:

sudo apt update && sudo apt upgrade 

Let’s begin the LEMP (Linux, Nginx, MySQL, and PHP) stack installation on Ubuntu 22.04 Jammy Jellyfish Linux system.

Step 1 – Installing NGINX

First, we will install the Latest Nginx web server on our system. Use the following commands to add PPA for installing the latest Nginx version on your Ubuntu 22.04 Linux.

Use the following commands to install Nginx web server.

sudo apt install nginx 

This will install the Nginx web server and start the service.

Now, you need to allow webserver ports in the firewall. To allow ports 80 and 443 in the UFW firewall, execute the following commands.

sudo ufw allow 80/tcp 
sudo ufw allow 43/tcp 

Open a web browser on your system and type the server’s IP in the address bar. You will get the default Nginx server page

How to Install LEMP Stack on Ubuntu 22.04
Nginx Default Page

Step 2 – Installing PHP

First, you need to decide on the PHP version to install on your system. You can also install multiple PHP versions on a single system. Currently the repository contains PHP 5.6, PHP 7.1, 7.2, 7.3, 7.4 and PHP 8.0, 8.1. The below instruction will install PHP 8.1. Please change the version as per your requirements.

The ondrej/php ppa contains all PHP version’s for Ubuntu systems. So add this repository in your system with command below:

sudo add-apt-repository ppa:ondrej/php 

Now update the apt cache and install PHP 8.1.

sudo apt update 
sudo apt install php8.1 

This will install PHP on your Ubuntu system along with some useful PHP extensions.

Step 3 — Install and Configure PHP-FPM

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features. Nginx web server required php-fpm for processing the PHP scripts.

To install PHP-FPM, run the following command based on the installed PHP version:

sudo apt install php8.1-fpm 

Once the installation finished, check the service status:

sudo systemctl status php8.1-fpm 
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-04-07 06:26:55 UTC; 11min ago
       Docs: man:php-fpm8.1(8)
    Process: 108650 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)
   Main PID: 108647 (php-fpm8.1)
     Status: "Processes active: 0, idle: 2, Requests: 2, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 1034)
     Memory: 10.7M
        CPU: 88ms
     CGroup: /system.slice/php8.1-fpm.service
             ├─108647 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)
             ├─108648 "php-fpm: pool www
             └─108649 "php-fpm: pool www

Apr 07 06:26:55 ubuntu2204 systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
Apr 07 06:26:55 ubuntu2204 systemd[1]: Started The PHP 8.1 FastCGI Process Manager.

In Step 6, we will configure the Nginx virtual host with PHP-FPM to serve PHP applications.

Step 4 – Installing MySQL

The default Ubuntu repositories contain MySQL 8.0. Which can be directly installed using the package manager. To install the available MySQL server version, execute the following command.

sudo apt-get install mysql-server 

Once the installation is finished, you can secure the MySQL server by executing the following command.

sudo mysql_secure_installation 

This will ask for a few questions to secure the MySQL server.

  1. Press ‘y’ to enable validate password plugin. This will allow you to set a strict password policy for user accounts.
    VALIDATE PASSWORD COMPONENT can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD component?
    
    Press y|Y for Yes, any other key for No: y
    
  2. Chose the password complexity level. Read all 3 options and choose one. For production servers we recommend to choose STRONG policy.
    LOW    Length >= 8
    MEDIUM Length >= 8, numeric, mixed case, and special characters
    STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
    
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
    
  3. Enter a new password and re-enter it. Make sure it matches the complexity level as described above.
    New password: *************
    Re-enter new password: *************
    
  4. Press ‘y’ to continue with provided password.
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    
  5. Remove default anonymous users from MySQL server:
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    
  6. Disable root login from remote systems
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    
  7. Remove test database form MySQL created by default during installation.
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    
  8. Reload all privileges to apply above changes immediately.
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    

You have secured the MySQL server in the LAMP stack on Ubuntu 22.04 Linux system.

Remember that the above password set for the root accounts is used for remote users only. To log in from the same system, just type mysql on terminal.

sudo mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.28-0ubuntu4 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Type ‘quit’ to exit from the MySQL shell and return to the system terminal.

Step 5 – Installing Additional Packages

You may also need to install modules like MySQL and other extensions for PHP based on the application requirements. Use the following command to find our available PHP extensions.

sudo apt search php8.1-* 

The above command will list all available PHP7 modules for installation, Let’s begin the installation of modules.

sudo apt install php8.1-mysql php8.1-curl php8.1-xml 

You may also need to install other required PHP extensions on your system.

Step 6 — Configure Nginx VirtualHost

Finally, do the configuration of the Nginx virtual host. For this example, we are editing the default configuration file.

sudo nano /etc/nginx/sites-enabled/default 

and make changes as below.

server {
        listen   80;

        root /var/www/example.com;
		
        index index.php;
		
        server_name  example.com www.example.com;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        }

}

In the above configuration file, look for location ~ \.php$ section. Which is required to service PHP scripts via Nginx server.

You have to do the same changes in all VirtualHosts configured.

Step 7 – Verify Setup

You have successfully completed the installation of Nginx, MySQL, and PHP on the Ubuntu 22.04 Linux system. To verify the PHP integration with Nginx, create a PHP script (example: info.php) on the website document root and write the below content.

<?php
   phpinfo();
?>

Now access this file in the web browser. It will so all the details about versions and installation.

http://server-ip-or-domain-name/info.php 
Running PHP Script with Nginx and PHP-FPM

Conclusion

This tutorial helped you to set up the LEMP (Linux, Nginx, MySQL, and PHP) stack on Ubuntu 22.04 LTS system. Now, you can host PHP-based web applications on your server.

The post How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-lemp-stack-on-ubuntu-22-04/feed/ 4
How To Install MySQL Server on Ubuntu 22.04 https://tecadmin.net/how-to-install-mysql-server-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-mysql-server-on-ubuntu-22-04/#respond Wed, 06 Apr 2022 01:42:00 +0000 https://tecadmin.net/?p=6058 MySQL is the most popular Open Source SQL database management system. It is developed and supported by Oracle Corporation. MySQL is widely used on Linux systems. Now MySQL providers also provide their own apt repository for installing MySQL on Ubuntu systems. This tutorial will help you to install the MySQL server on Ubuntu 22.04 Jammy [...]

The post How To Install MySQL Server on Ubuntu 22.04 appeared first on TecAdmin.

]]>
MySQL is the most popular Open Source SQL database management system. It is developed and supported by Oracle Corporation. MySQL is widely used on Linux systems. Now MySQL providers also provide their own apt repository for installing MySQL on Ubuntu systems.

This tutorial will help you to install the MySQL server on Ubuntu 22.04 Jammy Jellyfish Linux systems.

Prerequisities

You must have a running Ubuntu 20.04 Linux system with sudo privileges user access.

Step 1 – Installing MySQL on Ubuntu 22.04

The default Ubuntu repositories contain MySQL 8.0. Which can be installed directly using the package manager without adding third-party PPA.

To install the available MySQL server version, execute the following command.

sudo apt-get install mysql-server 

Press ‘y’ for any confirmation asked by the installer.

Once the installation is finished, you can secure the MySQL server by executing the following command.

sudo mysql_secure_installation 

You will go through a wizard of questions to secure the MySQL server. Follow the onscreen instructions below:

  1. Press ‘y’ to enable validate password plugin. This will allow you to set a strict password policy for user accounts.
    VALIDATE PASSWORD COMPONENT can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD component?
    
    Press y|Y for Yes, any other key for No: y
    
  2. Chose the password complexity level. Read the all 3 options and choose one:
    LOW    Length >= 8
    MEDIUM Length >= 8, numeric, mixed case, and special characters
    STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
    
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
    
  3. Enter a new password and re-enter it. Make sure it matches the complexity level as described above.
    New password: *************
    Re-enter new password: *************
    
  4. Press ‘y’ to continue with provided password.
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    
  5. Remove default anonymous users from MySQL server:
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    
  6. Disable root login from remote systems
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    
  7. Remove test database form MySQL created by default during installation.
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    
  8. Reload all privileges to apply above changes immediately.
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    

You have secured the MySQL server in the LAMP stack on Ubuntu 22.04 Linux system.

Step 2 – Connect to MySQL Server

Remember that the above password set for the root accounts is used for remote users only. To log in from the same system, just type mysql on terminal.

sudo mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.28-0ubuntu4 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Step 3 – Creating Database and Users

Here is few example queries to create database and users in MySQL server.

  • Create a database named ‘mydb’.
    CREATE DATABASE mydb; 
    
  • Next, create a user named ‘myuser’ accessible from ‘localhost’ only.
    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'secure_password_'; 
    
  • Grant permissions on database to user.
    GRANT ALL ON mydb.* to 'myuser'@'localhost'; 
    
  • Apply the permission changes at runtime.
    FLUSH PRIVILEGES; 
    

Step 4 – Manage MySQL Service

  • To check the database server status.
    sudo systemctl status mysql 
    
  • Use below command to start MySQL server.
    sudo systemctl start mysql 
    
  • To stop MySQL server:
    sudo systemctl stop mysql 
    
  • Restart MySQL database server, type:
    sudo systemctl restart mysql 
    

Step 5 – Uninstall (Remove) MySQL Server

If you no longer need to use the MySQL server, uninstall it from your server.

Warning – This will remove all databases from your system. Please backup all the databases in a safe place.

To remove MySQL server type:

sudo apt purge mysql-server-* 

To completely uninstall MySQL, remove the following folders as well.

rm -rf /etc/mysql 
rm -rf /var/lib/mysql 

Conclusion

This tutorial helped you to install the MySQL server on Ubuntu 20.04 LTS Linux system. Also includes instructions to secure the database server and uninstall it.

The post How To Install MySQL Server on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-mysql-server-on-ubuntu-22-04/feed/ 0
How To Install MariaDB on Debian 11 https://tecadmin.net/how-to-install-mariadb-on-debian-11/ https://tecadmin.net/how-to-install-mariadb-on-debian-11/#comments Mon, 27 Sep 2021 13:58:46 +0000 https://tecadmin.net/?p=27882 MySQL is a well-liked free database management system and also a prominent component of the LAMP stack. MySQL has been replaced with MariaDB in Debian repositories, which is a decent alternative to MySQL and pretty much performs every operation that MySQL performs. MySQL is currently not available for Debian 11 Bullseye, so MariaDB is a [...]

The post How To Install MariaDB on Debian 11 appeared first on TecAdmin.

]]>
MySQL is a well-liked free database management system and also a prominent component of the LAMP stack. MySQL has been replaced with MariaDB in Debian repositories, which is a decent alternative to MySQL and pretty much performs every operation that MySQL performs.

MySQL is currently not available for Debian 11 Bullseye, so MariaDB is a perfect choice. This article is focusing on how to install MariaDB, an alternative to MySQL on Debian 11.

Install MariaDB on Debian 11

The MariaDB packages are available under the official repositories. You can directly install it without adding an extra repo to your system. For this tutorial, we will install MariaDB on Debian 11 system via default repositories.

Firstly, update the packages list using:

sudo apt update 

Now, to install MariaDB, execute the below-mentioned command:

sudo apt install mariadb-server 

Configure MariaDB on Debian

To configure MariaDB properly we need to run a security script using the below-mentioned command:

sudo mysql_secure_installation 

After running the above command, you will be prompted with various options:

Secure Installation wizzard 1

Secure Installation wizzard 2

The options are self-explanatory, for the first two options choose “n” and for the next sequence of options press “y” for yes.

Create Privileges User with Authentication

For security purposes, MariaDB uses a unix_socket plugin to authenticate the root user. This may cause complications therefore, it is recommended to set a new user with password-based access. And to create a new user login to MariaDB using:

sudo mysql  

Now create a new user with a password in the MariaDB server.

CREATE USER 'admin'@'localhost' IDENTIFIED BY '_pa$$w0rd_'; 

Make sure to change admin with your username and _pas$$w0rd_ with a new secure password.

Next, grant permissions on all databases to a newly created account. Here the GRANT OPTION allow a user to create other users and assign them permissions.

GRANT ALL ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;  

Apply the new changes, execute:

FLUSH PRIVILEGES;  

And to quit typing “exit”.

EXIT 

The SQL statements are case insensitive, So you can write them in any case.

Connect MariaDB Server

One can manage MariaDB service using the Systemd. To test the status of MariaDB use the following command:

sudo systemctl status mariadb 

If for some reasons MariaDB is not running then use the below-mentioned command to start it:

sudo systemctl start mariadb 

For one more check you can try to connect to the database using:

sudo mysqladmin version 
Output
mysqladmin Ver 9.1 Distrib 10.5.11-MariaDB, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.5.11-MariaDB-1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /run/mysqld/mysqld.sock Uptime: 3 hours 45 min 24 sec Threads: 1 Questions: 497 Slow queries: 0 Opens: 171 Open tables: 28 Queries per second avg: 0.036

Next, connect to the MySQL shell by using the credentials created in the above step.

mysql -u admin -p 

The output of the above command asks for the password; use the password you set in the above steps. On successful authentication, you will get the MariaDB shell as below:

Output
Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 60 Server version: 10.5.11-MariaDB-1 Debian 11 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>

Conclusion

MariaDB is an open-source alternative to MySQL in the latest version of Debian. This write-up is a guide to install MariaDB on Debian 11 Bullseye. We learned how to install and configure MariaDB on Debian 11. We also created a separate user to manage the database with password access. Finally, we also discussed utilities to test the MariaDB status.

The post How To Install MariaDB on Debian 11 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-mariadb-on-debian-11/feed/ 2
How to Install Redis on Debian 11 Linux https://tecadmin.net/how-to-install-redis-on-debian-11/ https://tecadmin.net/how-to-install-redis-on-debian-11/#comments Thu, 16 Sep 2021 08:24:02 +0000 https://tecadmin.net/?p=27766 Redis is an open-source in-memory database for storing data structure, caching, and as a message broker. It supports data structures such as strings, lists, sets, hashes, sorted sets with range queries, bitmaps, HyperLogLogs, and geospatial indexes with radius queries. Redis has a built-in replication feature, which makes it work as highly available clusters in your [...]

The post How to Install Redis on Debian 11 Linux appeared first on TecAdmin.

]]>
Redis is an open-source in-memory database for storing data structure, caching, and as a message broker. It supports data structures such as strings, lists, sets, hashes, sorted sets with range queries, bitmaps, HyperLogLogs, and geospatial indexes with radius queries. Redis has a built-in replication feature, which makes it work as highly available clusters in your production environments.

This tutorial will help you to install Redis server on Debian 11 (Bullseye) Linux system.

Step 1: Updating System Packages

It’s a good practice to keep packages up to date on your system. You should always update the before beginning any major installations. Issue the command below:

sudo apt update 
sudo apt upgrade 

Step 2: Installing Redis on Debian 11

Redis 6.0 packages are available under the default Bullseye repositories. You can quickly install Redis by using the apt package manager on your Debian Linux system.

sudo apt install redis-server 

Once the installation is finished successfully, check the Redis service status by the below-mentioned command.

sudo systemctl status redis.service 
Redis Server Setup on Debian
Redis Service Status

Step 3: Configuring Redis

You can use Redis with the default settings from the local system. But in case you need to customize the Redis server like allowing access from remote hosts, changing the default port, or increasing the memory allocation.

Edit the Redis configuration file in a text editor:

sudo nano /etc/redis/redis.conf 

Now, make the required changes to the Redis server. Below are some quick uses changes in the Redis server.

  • Change Redis Port: You can run your Redis server to a non-standard port. This is good practice for security purposes. Search for the below section and update the port under port 6379.

    # Accept connections on the specified port, default is 6379 (IANA #815344).
    # If port 0 is specified Redis will not listen on a TCP socket.
    port 6379

  • Allow Remote Connection: Search for bind 127.0.0.1 ::1 line and comment it by adding “#” at start of line.

    # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    # JUST COMMENT OUT THE FOLLOWING LINE.
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # bind 127.0.0.1 ::1

  • Change Memory Allocation: Update the following values in the Redis configuration file according to your requirement. You can increase the max memory limit as per available memory on your server.

    maxmemory 256mb
    maxmemory-policy allkeys-lru

After doing the required changes, save the file. Then restart the Redis service to apply changes.

sudo systemctl restar redis.service 

Step 4: Connect to Redis

Type redis-cli on the command line to connect to the Redis server.

redis-cli 

You will get the Redis server prompt as below. Now type “ping” on the Redis command prompt. On successful connection with the Redis server, you will get PONG as a result.

 ping 
PONG

Conclusion

This tutorial helps you with the installation of the Redis server on the Debian 11 Bullseye Linux system.
You can find more details about the `redis-cli` command line tool from its official documentation.

The post How to Install Redis on Debian 11 Linux appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-redis-on-debian-11/feed/ 1
How To Install and Secure MongoDB on Ubuntu 20.04 https://tecadmin.net/how-to-install-mongodb-on-ubuntu-20-04/ https://tecadmin.net/how-to-install-mongodb-on-ubuntu-20-04/#respond Tue, 07 Sep 2021 09:00:04 +0000 https://tecadmin.net/?p=22000 MongoDB is a database and in comparison to other databases, it is easy to handle because there is no need to work in a table-based conventional relational database structure. We can save a large amount of data because of its feature of horizontal partitioning. A lot of companies are using MongoDB like CISCO, Facebook, Nokia, [...]

The post How To Install and Secure MongoDB on Ubuntu 20.04 appeared first on TecAdmin.

]]>
MongoDB is a database and in comparison to other databases, it is easy to handle because there is no need to work in a table-based conventional relational database structure. We can save a large amount of data because of its feature of horizontal partitioning. A lot of companies are using MongoDB like CISCO, Facebook, Nokia, etc.

MongoDB offers data aggregation as it allows us to store data according to our preferences. Otherwise, we have to manage data according to the data management of a conventional database.

This article will help us to understand how to install MongoDB in Ubuntu 20.04.

Prerequisites

You must have shell access to the Ubuntu system with sudo privileged account.

Installing MongoDB on Ubuntu

01. Open the terminal and add the repository key of MongoDB to the apt keyring. We can do this by following commands. It will ask for a password:

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - 

02. Now, we will add the MangoDB repository to our repository list by editing in the system’s list of sources. To access the editor of the system’s list we open the source list:

sudo nano /etc/apt/sources.list.d/mongodb.list 

Add the following line in the file as shown in the image:

deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse
MongoDB 5.0 PPA for Ubuntu 20.04
MongoDB 5.0 PPA for Ubuntu 20.04

Press CTRL + O to save changes and CTRL + X to exit from the editor.

03. Update the apt repository and then install the Mongodb server packages.

sudo apt update 
sudo apt install mongodb-org 

This will install the MongoDB server on your system along with the required dependencies.

04. Now, start the MongoDB daemon using the systemctl utility. Also, enable the service to auto-start on system reboot.

sudo systemctl enable mongod 
sudo systemctl start mongod 

05. Once the service started successfully, check the service status by typing the following command.

sudo systemctl status mongod 

06. Type “mongo” command on terminal and run to connect to the mongo shell:

mongo 

That’s it, the MongoDB server is up and running on your system.

Enable Authorization in MongoDB

By default, anyone can access MongoDB and can make changes to it. To secure it we will enable user authentication on the MongoDB server. This will prevent anonymous access to the database server.

Login to the Mongo shell:

mongo 

We will type “use admin” in the mongo shell so now we are in its administration section.

use admin

Next, create a user account with admin privileges in MongoDB.

db.createUser(
  {
    user: "tecadmin",
    pwd: "Pa$$w0rd",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)
Create Admin Account in MongoDB
Create Admin Account in MongoDB

Now exit the editor by pressing CTRL + C.

Next we need to enable security in MongoDB configuration file. Edit the mongo configuration file by using:

sudo nano /etc/mongod.conf 

The setting will be open and go to the “#security” section. Remove the “ # ” and type “authorization: enabled”.

MongoDB Enable Authorization
MongoDB Enable Authorization

Now exit by pressing CTRL + x, type “ y ” and press ENTER to exit by saving the file. Now restart the MongoDb and then check its status:

sudo systemctl restart mongod 

Now the database is secured, only admin users can access it by entering the set password. Use the following command to connect to the MongoDB server.

mongo -u tecadmin -p 
Output:
MongoDB shell version v5.0.2 Enter password: connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("0876c195-18dc-4e6c-a0c8-368364f10d03") } MongoDB server version: 5.0.2 ================ Warning: the "mongo" shell has been superseded by "mongosh", which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in an upcoming release. We recommend you begin using "mongosh". For installation instructions, see https://docs.mongodb.com/mongodb-shell/install/ ================ >

Conclusion

If we are doing a startup project and you know you have to make a lot of changes then MongoDB is the best database to work with as compared to conventional databases. In this article, we learned about MongoDB and how we can install and secure MongoDB on Ubuntu 20.04.

The post How To Install and Secure MongoDB on Ubuntu 20.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-mongodb-on-ubuntu-20-04/feed/ 0
How To Install and Secure MongoDB on CentOS 8 https://tecadmin.net/how-to-install-and-secure-mongodb-on-centos-8/ https://tecadmin.net/how-to-install-and-secure-mongodb-on-centos-8/#respond Wed, 18 Aug 2021 09:12:04 +0000 https://tecadmin.net/?p=27253 MongoDB is a popularly used document-oriented, NoSQL, database program. The term NoSQL refers to not only SQL which is an approach to designing databases. A NoSQL database is modeled in a way that the storage and retrieval of data are done through documents, instead of using the tabular structure (tables and rows) used in the [...]

The post How To Install and Secure MongoDB on CentOS 8 appeared first on TecAdmin.

]]>
MongoDB is a popularly used document-oriented, NoSQL, database program. The term NoSQL refers to not only SQL which is an approach to designing databases. A NoSQL database is modeled in a way that the storage and retrieval of data are done through documents, instead of using the tabular structure (tables and rows) used in the more traditional relational databases.

MongoDB is a general-purpose database in which data is stored in flexible JSON-like documents in key-value pairs. Each MongoDB database has collections that contain documents. These documents can have different sizes, contents, and numbers of fields. It supports an optional schema model which means that the blueprint of the database doesn’t need to be defined beforehand. The MongoDB databases are very scalable.

The document-oriented model makes MongoDB very flexible. It is great at load balancing and duplicating data and can run on multiple servers. These features allow it to keep the system running even if there is hardware failure. Following are some of the key features of MongoDB:

  • Ad-hoc queries
  • Indexing
  • Aggregation
  • Load balancing
  • Capped collections
  • Replication

How to install MongoDB on CentOS 8

To install MongoDB on your system you must be logged in as a root user or have sudo privileges.

MongoDB is not available by default in CentOS 8 repositories. So, first, we will have to create a new file and add MongoDB to the repositories of CentOS 8. Use the below-given command to create a new file:

sudo nano /etc/yum.repos.d/mongodb-org-5.0.repo 

Now copy and paste the following text into the text file created above, so you can install MongoDB directly from the terminal:

[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc

Save the file and close it.

Now to install MongoDB use the command given below:

sudo dnf install mongodb-org -y
dnf install mongodb on centos8
Installing MongoDB with DNF

The command given above will install the newest stable version of MongoDB. As of now, it is 5.0. You can visit MongoDB’s official website to check out the latest version. If you want to install a specific version then replace 5.0 with your preferred version in the text file.

To verify the installation, run the MongoDB database:

mongo
Connect Mongo Shell
Connect Mongo Shell via CLI

Now execute the below-given command to check the version installed on your system:

db.version() 
Output:
5.0.1

Now, use the following command to exit the shell:

exit 

Once the installation process is completed, start MongoDB by using the below-mentioned command:

sudo systemctl start mongod

Now enable the MongoDB service using the command given below.

sudo systemctl enable mongod

You can use the below-given command to check the status of the MongoDB service:

sudo systemctl status mongod
Check MongoDB Service
MongoDB Service Status

How to Enable MongoDB Authentication

Now that we have successfully installed MongoDB on our system, we will configure it to make it more secure.

Authentication is disabled by default for MongoDB. This allows any user to modify, create, delete or interact with databases. It is recommended to enable authentication and restrict access to MongoDB. MongoDB authentication can be enabled by editing the following configuration file:

nano /etc/mongod.conf 

After opening the config file in your preferred browser search for #security. Uncomment the security section by removing the # sign and add authorization: enabled on the next line. The “authorization: enabled” line should be indented by using two spaces. The config file should look something like this after you are done editing it:

Enabling authorization in Mongodb
Enabling Authorization in Mongodb Server

Save and exit the file using Ctrl + X if you’re using Nano. Now to apply the changes to MongoDB; restart the service using the following command:

systemctl restart mongod 

You can again check the status of the MongoDB service to verify if the service has restarted successfully by using the above-mentioned command.

How to Create an Admin user for MongoDB

Now we will create an admin user for MongoDB who will have all the administrative privileges. To create a new MongoDB admin user, first access the MongoDB service by using the following command:

mongo 

Now execute the following command to use the service as an admin:

use admin

Now use the below given command to create a new user:

db.createUser( { user: "admin1", pwd: "pass", roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] } )

You can replace admin1 and pass with your preferred username and password.

Create an Admin User in MongoDB
Create an Admin User in MongoDB

Now exit the shell by using the below-given command:

exit

How to verify MongoDB Authentication

Now you will not be able to run a command on the MongoDB shell without authentication as we have configured it to make authentication necessary.

You can open the MongoDB service and try to run different commands to verify this:

show users
MongoDB Authorization Error
MongoDB Error without Authorization
show dbs

In the example above no output has been shown as the access is now restricted.

You can access the MongoDB service with the administrative user by using the command given below:

mongo -u admin1 -p --authenticationDatabase admin 

Now if I use the show dbs command again, I get the following output:

show dbs
Output:
admin 0.000GB config 0.000GB local 0.000GB

Conclusion

MongoDB is a free, open-source, NoSQL database. It offers developers a lot more flexibility than traditional relational-based databases. It stores data in JSON-like documents which allows faster and efficient data transfer between the client and the database.

In this comprehensive guide, we learned to install and configure MongoDB on CentOS 8 operating system.

The post How To Install and Secure MongoDB on CentOS 8 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-and-secure-mongodb-on-centos-8/feed/ 0