• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Sunday, June 15, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to set up a database server on Debian using MySQL or PostgreSQL

in Debian, Linux OS

Setting up a database server on Debian can be a daunting task for many users, but with the right guidance, it can be a simple and straightforward process. In this blog, we will discuss how to set up a database server on Debian using MySQL or PostgreSQL.

Step 1: Update and upgrade the system

Before we begin the installation process, it’s essential to update and upgrade the system. Open the terminal and run the following command:

sudo apt-get update
sudo apt-get upgrade

Step 2: Install MySQL or PostgreSQL

Debian has both MySQL and PostgreSQL in its repository. To install MySQL, run the following command:

sudo apt-get install mysql-server

To install PostgreSQL, run the following command:

sudo apt-get install postgresql postgresql-contrib

Step 3: Configure MySQL or PostgreSQL

After the installation, we need to configure MySQL or PostgreSQL.

To configure MySQL, run the following command:

sudo mysql_secure_installation

Follow the on-screen prompts and set a password for the root user.

To configure PostgreSQL, open the configuration file by running the following command:

sudo nano /etc/postgresql/12/main/pg_hba.conf

Find the line that says “local all postgres peer” and change it to “local all postgres md5”. Save the file and exit.

Step 4: Start the service

To start the MySQL service, run the following command:

sudo systemctl start mysql

To start the PostgreSQL service, run the following command:

sudo systemctl start postgresql

Step 5: Test the database server

To test the database server, we can log in to the MySQL or PostgreSQL server using the following commands:

sudo mysql -u root -p

or

sudo -u postgres psql

After entering the password, we should be able to access the MySQL or PostgreSQL command line.

Step 6: Create a new database and user

To create a new database and user in MySQL, run the following commands:

CREATE DATABASE dbname;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost';

Replace dbname, username, and password with the desired names.

To create a new database and user in PostgreSQL, run the following commands:

CREATE DATABASE dbname;
CREATE USER username WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE dbname TO username;

Replace dbname, username, and password with the desired names.

Step 7: Restart the service

After creating a new database and user, we need to restart the MySQL or PostgreSQL service.

To restart the MySQL service, run the following command:

sudo systemctl restart mysql

To restart the PostgreSQL service, run the following command:

sudo systemctl restart postgresql

Conclusion:

Setting up a database server on Debian using MySQL or PostgreSQL can be a challenging task, but by following the steps outlined above, it can be a straightforward process. Remember to update and upgrade the system, install and configure the database server, start the service, test the database server, create a new database and user, and restart the service. With these steps, we can have a fully functional database server running on Debian.

ShareTweet
Previous Post

How to configure and manage storage devices in Debian using LVM

Next Post

How to install and configure virtualization software on Debian with KVM

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.