AlmaLinuxRHEL Based

How To Install SQLite on AlmaLinux 9

Install SQLite on AlmaLinux 9

SQLite is a powerful, self-contained, and serverless relational database management system that has gained immense popularity among developers and system administrators. Its lightweight nature and ease of use make it an excellent choice for various applications, from mobile apps to desktop software. In this comprehensive guide, we’ll walk you through the process of installing SQLite on AlmaLinux 9, a robust and enterprise-ready Linux distribution.

AlmaLinux 9, known for its stability and compatibility with Red Hat Enterprise Linux (RHEL), provides an ideal platform for running SQLite. Whether you’re a seasoned database administrator or a newcomer to the world of relational databases, this article will equip you with the knowledge and skills needed to successfully install and configure SQLite on your AlmaLinux 9 system.

Understanding SQLite and AlmaLinux 9

What is SQLite?

SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. It is the most widely deployed database engine in the world, used in countless applications across various platforms. Unlike traditional client-server database management systems, SQLite doesn’t require a separate server process or system to operate. Instead, it reads and writes directly to ordinary disk files, making it incredibly portable and easy to use.

Key Features and Benefits of SQLite

  • Serverless: No need for a separate database server
  • Zero-configuration: Requires no setup or administration
  • Cross-platform: Works on various operating systems
  • Compact: The entire database is stored in a single file
  • ACID-compliant: Ensures data integrity and reliability
  • Public domain: Free for use in both commercial and private projects

Prerequisites for Installing SQLite on AlmaLinux 9

Before we dive into the installation process, let’s ensure you have everything needed to successfully install SQLite on your AlmaLinux 9 system.

System Requirements

  • A machine running AlmaLinux 9 (minimal or full installation)
  • At least 1GB of RAM (2GB or more recommended)
  • Sufficient disk space (at least 10GB free space)
  • A stable internet connection for downloading packages

User Permissions and Sudo Access

To install SQLite and perform system-wide changes, you’ll need root or sudo privileges. Ensure you have the necessary permissions before proceeding with the installation.

Internet Connectivity

A stable internet connection is crucial for downloading SQLite packages and any required dependencies. Make sure your AlmaLinux 9 system is connected to the internet before starting the installation process.

Updating AlmaLinux 9 System

Before installing SQLite, it’s essential to update your AlmaLinux 9 system to ensure you have the latest security patches and software versions.

Importance of System Updates

Keeping your system up-to-date offers several benefits:

  • Enhanced security by patching known vulnerabilities
  • Improved system stability and performance
  • Access to the latest features and improvements
  • Compatibility with newer software versions

Step-by-Step Guide to Update AlmaLinux 9

Follow these steps to update your AlmaLinux 9 system:

  1. Open a terminal window
  2. Run the following command to update the package list:
    sudo dnf update
  3. When prompted, enter your sudo password
  4. Review the list of packages to be updated and press ‘y’ to confirm
  5. Wait for the update process to complete
  6. Reboot your system if necessary:
    sudo reboot

Installing SQLite on AlmaLinux 9

Now that your system is up-to-date, let’s proceed with installing SQLite. We’ll cover two methods: using the DNF package manager and installing from source.

Using DNF Package Manager

The DNF (Dandified Yum) package manager is the preferred method for installing software on AlmaLinux 9. Follow these steps to install SQLite using DNF:

  1. Open a terminal window
  2. Run the following command to install SQLite:
    sudo dnf install sqlite
  3. When prompted, enter your sudo password
  4. Review the package information and press ‘y’ to confirm the installation
  5. Wait for the installation to complete

Installing SQLite from Source

For those who prefer to compile SQLite from source or need a specific version not available in the repositories, follow these steps:

  1. Install the necessary development tools:
    sudo dnf groupinstall "Development Tools"
  2. Download the SQLite source code:
    wget https://www.sqlite.org/2024/sqlite-autoconf-3460100.tar.gz
    
  3. Extract the downloaded archive:
    tar xvfz sqlite-autoconf-3460100.tar.gz
  4. Navigate to the extracted directory:
    cd sqlite-autoconf-3460100
  5. Configure the build:
    ./configure --prefix=/usr/local
  6. Compile the source code:
    make
  7. Install SQLite:
    sudo make install

Verifying the Installation

To ensure SQLite has been installed correctly, run the following command:

sqlite3 --version

This should display the installed SQLite version number.

Configuring SQLite on AlmaLinux 9

After successfully installing SQLite, it’s time to configure it for optimal performance on your AlmaLinux 9 system.

Setting up Environment Variables

To make SQLite easily accessible from any location in your system, add its installation directory to your PATH environment variable:

  1. Open your shell configuration file (e.g., ~/.bashrc) in a text editor:
    nano ~/.bashrc
  2. Add the following line at the end of the file:
    export PATH="/usr/local/bin:$PATH"
  3. Save the file and exit the editor
  4. Apply the changes by running:
    source ~/.bashrc

Creating a Sample Database

Let’s create a simple database to test our SQLite installation:

  1. Open the SQLite shell:
    sqlite3 test_db.sqlite
  2. Create a table:
    CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);
  3. Insert some data:
    INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com');
    INSERT INTO users (name, email) VALUES ('Jane Smith', 'jane@example.com');
  4. Verify the data:
    SELECT * FROM users;
  5. Exit the SQLite shell:
    .quit

Basic SQLite Commands

Here are some essential SQLite commands to get you started:

  • .tables – List all tables in the database
  • .schema TABLE_NAME – Show the schema for a specific table
  • .dump – Display the entire database as SQL statements
  • .mode column – Set output mode to columnar format
  • .headers on – Show column headers in query results

Testing SQLite Installation

To ensure your SQLite installation is functioning correctly, let’s perform some basic tests.

Running SQLite Shell

Open the SQLite shell by running:

sqlite3

You should see the SQLite prompt, indicating that the shell is ready for input.

Install SQLite on AlmaLinux 9

Executing Basic SQL Queries

Try running the following SQL queries to test various features of SQLite:

  1. Create a new database:
    sqlite3 test.db
  2. Create a table:
    CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, price REAL);
  3. Insert data:
    INSERT INTO products (name, price) VALUES ('Widget', 9.99);
    INSERT INTO products (name, price) VALUES ('Gadget', 24.99);
  4. Query data:
    SELECT * FROM products WHERE price < 20;
  5. Update data:
    UPDATE products SET price = 14.99 WHERE name = 'Widget';
  6. Delete data:
    DELETE FROM products WHERE name = 'Gadget';

Troubleshooting Common Issues

If you encounter any problems while testing SQLite, consider the following troubleshooting steps:

  • Verify that SQLite is in your system PATH
  • Check file permissions for the database file
  • Ensure you have write access to the directory where you’re creating the database
  • Confirm that your SQL syntax is correct

Congratulations! You have successfully installed SQLite. Thanks for using this tutorial for installing SQLite on AlmaLinux 9 system. For additional help or useful information, we recommend you check the SQLite website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button