This is guide, howto install PostgreSQL 18.1 / 17.7 / 16.11 database server on Fedora 43/42 and RHEL/CentOS/Rocky/Alma 10/9/8. The guide shows how to install PostgreSQL 18.1 / 17.7 / 16.11 from the PostgreSQL Global Development Group (PGDG) repositories and also how to install the distro-provided package where appropriate. Use the detection commands in the installation section to list available majors in your enabled repositories.
Check video guide howto install PostgreSQL on Fedora / Rocky (example older recordings):
Psql is a good tool for the PostgreSQL database management and use. Psql client functioning can easily be improved by adding a few lines ~/.psqlrc file.
1. Tuning psqlrc 1.1 Set all null fields to NULL: \pset null 'NULL' After this, the query results look like this:
select 'test' as test_text, null as test_null; test_text | test_null -----------+----------- test | NULL (1 row) 1.2 Set the command history file names for each host and database: \set HISTFILE ~/.psql_history- :HOST - :DBNAME After this, the history file naming look like this:
PostgreSQL table partitioning means splitting one large database table into smaller logical pieces. PostgreSQL table partitioning will be worthwhile only when a table would be very large.
Here are a few benefits of what can be achieved with partitioning:
Large tables query performance can be improved dramatically Reducing index size and making it more likely that the heavily-used parts of the indexes fit in memory Rarely used data can be moved to slower and cheaper storage media This topic is divided into three parts, which are as follows and published in the following order: Part 1. Howto create PostgreSQL table partitioning
PostgreSQL supports partitioning via table inheritance. So the partitioning is made in such a way that every child table inherits single parent table. Parent table is empty and it exists just to describe the whole data set.
PostgreSQL partitioning can be implemented in range partitioning or list partitioning.
Range partitioning can be done for example by ID ranges (like 0-100 000, 100 001-200 000, 200 001-300 000…) or Date ranges (like 2009-11-01 – 2009-11-30, 2009-12-01 – 2009-12-31…). List partitioning can be done for example by list of cities (like New York, Los Angeles, Chicago, Houston, Philadelphia…) or list of categories (like Programming, Home, Food…). It’s important to ensure that there is no overlap between the key values permitted in different partitions.
As Part 1 (Howto create PostgreSQL table partitioning) shows, making of PostgreSQL partitioning needs a lot of SQL commands. So this Part 2 explains how SQL commands for PostgreSQL partitioning can be made with a simple PHP script. This example script make SQL for child tables, indexes, trigger function and parent table trigger. This example script can make PostgreSQL table partitioning with using Date ranges. Script can be configured with following configuration section:
This article compares the speed and performance of queries between partitioned and non partitioned PostgreSQL tables. However, it is important to remember that the PostgreSQL tables partitioning has also another benefits, than the better performance on queries. More information about other benefits from the first part ‘Howto create PostgreSQL table partitioning (Part 1)‘.
This is comparision between partitioned and non partitioned PostgreSQL tables. The same tests were carried out with and without indices, because using the indices, it is no longer very meaningful example on table, which has one billion rows of data (if the table is not partitioned). This comparison is used an example of an existing table, which looks like this:
This is guide howto install nginx, PHP 5.3 and FastCGI webserver with MySQL and/or PostgreSQL and Memcache support on Fedora 12 and Fedora 13, CentOS 5.5, Red Hat (RHEL) 5.5/6.
nginx (engine x) is a robust, small and high performance http server, reverse proxy server and also mail proxy server.
1. Add and enable needed repositories: Updated 19.3.2010 Use following repositories to install nginx 0.8.xx version (currently 0.8.36 version)
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm rpm -Uvh http://yum.chrislea.com/centos/5/i386/chl-release-5-3.noarch.rpm rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CHL Just Epel repository is now obsolete, since there can be found only nginx 0.6.xx branch (currenlty version 0.6.39) Check this comment for more info.
This is quick guide howto install PostgreSQL 8.4 (current stable 8.4.7) database server on CentOS, Fedora and Red Hat. Fedora 14, Fedora 13, CentOS 5.5 and Red Hat (RHEL) 5.5 has PostgreSQL 8.4 database server as default so extra repositories is not needed. Personally, I like to use Postgres own repositories, because the latest version of PostgreSQL may be quickly and easily installed. The following commands run as root and postgres user, so “su -” or “sudo -i” first.
One day, I was looking for PostgreSQL database function, which could delay the execution of queries. At first I thought that I will do one myself, because I do not remember ever seen this kind function. But then I found pg_sleep Postgres function which directly delay execution of the server process.
pg_sleep makes the current session’s process sleep until seconds seconds have elapsed. Seconds is a value of type double precision, so fractional-second delays can be specified.
This is quick tip howto select a random number in a range. Example random number between 1-100 (>= 1 and random() function, which returns random value between 0-1. Following example selects 5 random values using generate_series() function:
SELECT random() FROM generate_series(1,5); random ------------------- 0.595817462075502 0.350072300527245 0.989073566626757 0.700899163261056 0.940509075298905 (5 rows) Next thing to todo is convert random function values to real float values in a range 1-100:
SELECT random() * 99 + 1 FROM generate_series(1,5); ?column? ------------------ 45.0829070857726 96.3123500789516 30.1867960244417 63.0484761050902 44.2645903658122 (5 rows) And finally truncate floats to integers with trunc function:
Are you looking MariaDB Install guide?
MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. This is guide, howto install or upgrade Oracle MySQL Community Server latest version 8.0 (8.0.27) on Fedora 35/34/33, CentOS 8, Red Hat (RHEL) 8.5 and Rocky Linux 8.5. This guide works of course with Oracle Linux and Scientific Linux too.
LAMP (Linux, Apache, MariaDB/MySQL, PHP) server is very powerful server setup behind any website or web based service. This guide is collection of Fedora/CentOS/Red Hat (RHEL), Apache, MariaDB/MySQL and PHP install guides.
Today the Internet is full of instructions, which promises a LAMP server installation with a “One-Liner”, and so forth. In fact, these “One-Liner” instructions assume that, Linux is already installed and installs just AMP (Apache, MariaDB/MySQL, PHP) pakages, without any configuration. AMP programs can be installed with one command easily, of course, but the correct configuration have to be done anyway, especially if the environment is going to production use.
This is guide, howto install WordPress 4.1.1 with Nginx or Apache on Fedora 21/20/19, CentOS 7/6.6/5.11 and Red Hat (RHEL) 7/6.6/5.11 servers. WordPress needs web server with PHP and MariaDB or MySQL database. This guide uses Apache web server with PHP 5.6 or Nginx web server with PHP 5.6 (PHP-FPM) and MariaDB 10/5.5 database server or Mysql 5.6 database server.
If you want to install WordPress with Apache then use a – [Apache] sections and if you want install WordPress with Nginx then use b – [Nginx] sections.
LEMP (Linux, Nginx, MySQL, PHP) server is extremely powerful setup behind any website or web based service. This guide is collection of Fedora/CentOS/Red Hat (RHEL), Nginx, MariaDB/MySQL and PHP (PHP-FPM) install guides.
This guide (more specifically this guide parts) try to explain in more detail LEMP (Linux, Nginx, MariaDB/MySQL, PHP (PHP-FPM)) server environment installation. This howto can be used to pre-installed Linux, and instructions can be used for various Fedora and Red Hat based Linux distros with YUM. This guide is also usable with setup where MariaDB/MySQL databases, Nginx servers and even PHP-FPM are on different server machines. So you could have different servers to process MariaDB/MySQL queries, Web Server requests and PHP requests.
This is a PHP, PDO and SQLite3 example, which demonstrates the SQLite3 databse usage with PHP-PDO. The PHP / PDO / SQLite3 example code demonstrates following things, and their use:
Create / Connect SQLite3 databases Use SQLite3 file and memory databases Create tables in SQLite3 database Use SQLite3 db different datetime formats Insert data to SQLite3 database PDO / SQLite3 prepared statements Bind parameters to statement variables Bind values to statement variables Quote a string for use in a query Update data in SQLite3 database Select / Query from SQLite3 database and print query output Drop SQLite3 table Close SQLite3 connections PHP / PDO / SQLite3 Example Code <?php // Set default timezone date_default_timezone_set('UTC'); try { /************************************** * Create databases and * * open connections * **************************************/ // Create (connect to) SQLite database in file $file_db = new PDO('sqlite:messaging.sqlite3'); // Set errormode to exceptions $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Create new database in memory $memory_db = new PDO('sqlite::memory:'); // Set errormode to exceptions $memory_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /************************************** * Create tables * **************************************/ // Create table messages $file_db->exec("CREATE TABLE IF NOT EXISTS messages ( id INTEGER PRIMARY KEY, title TEXT, message TEXT, time INTEGER)"); // Create table messages with different time format $memory_db->exec("CREATE TABLE messages ( id INTEGER PRIMARY KEY, title TEXT, message TEXT, time TEXT)"); /************************************** * Set initial data * **************************************/ // Array with some test data to insert to database $messages = array( array('title' => 'Hello!', 'message' => 'Just testing...', 'time' => 1327301464), array('title' => 'Hello again!', 'message' => 'More testing...', 'time' => 1339428612), array('title' => 'Hi!', 'message' => 'SQLite3 is cool...', 'time' => 1327214268) ); /************************************** * Play with databases and tables * **************************************/ // Prepare INSERT statement to SQLite3 file db $insert = "INSERT INTO messages (title, message, time) VALUES (:title, :message, :time)"; $stmt = $file_db->prepare($insert); // Bind parameters to statement variables $stmt->bindParam(':title', $title); $stmt->bindParam(':message', $message); $stmt->bindParam(':time', $time); // Loop thru all messages and execute prepared insert statement foreach ($messages as $m) { // Set values to bound variables $title = $m['title']; $message = $m['message']; $time = $m['time']; // Execute statement $stmt->execute(); } // Prepare INSERT statement to SQLite3 memory db $insert = "INSERT INTO messages (id, title, message, time) VALUES (:id, :title, :message, :time)"; $stmt = $memory_db->prepare($insert); // Select all data from file db messages table $result = $file_db->query('SELECT * FROM messages'); // Loop thru all data from messages table // and insert it to file db foreach ($result as $m) { // Bind values directly to statement variables $stmt->bindValue(':id', $m['id'], SQLITE3_INTEGER); $stmt->bindValue(':title', $m['title'], SQLITE3_TEXT); $stmt->bindValue(':message', $m['message'], SQLITE3_TEXT); // Format unix time to timestamp $formatted_time = date('Y-m-d H:i:s', $m['time']); $stmt->bindValue(':time', $formatted_time, SQLITE3_TEXT); // Execute statement $stmt->execute(); } // Quote new title $new_title = $memory_db->quote("Hi''\'''\\\"\"!'\""); // Update old title to new title $update = "UPDATE messages SET title = {$new_title} WHERE datetime(time) > datetime('2012-06-01 15:48:07')"; // Execute update $memory_db->exec($update); // Select all data from memory db messages table $result = $memory_db->query('SELECT * FROM messages'); foreach($result as $row) { echo "Id: " . $row['id'] . "\n"; echo "Title: " . $row['title'] . "\n"; echo "Message: " . $row['message'] . "\n"; echo "Time: " . $row['time'] . "\n"; echo "\n"; } /************************************** * Drop tables * **************************************/ // Drop table messages from file db $file_db->exec("DROP TABLE messages"); // Drop table messages from memory db $memory_db->exec("DROP TABLE messages"); /************************************** * Close db connections * **************************************/ // Close file db connection $file_db = null; // Close memory db connection $memory_db = null; } catch(PDOException $e) { // Print PDOException message echo $e->getMessage(); } ?> Example Code Output Id: 1 Title: Hello! Message: Just testing... Time: 2012-01-23 06:51:04 Id: 2 Title: Hi''\'''\""!'" Message: More testing... Time: 2012-06-11 15:30:12 Id: 3 Title: Hi! Message: SQLite3 is cool... Time: 2012-01-22 06:37:48
This is guide, howto install phpMyAdmin 4.3.10 with Nginx or Apache on Fedora 21/20/19, CentOS 7/6.6/5.11 and Red Hat (RHEL) 7/6.6/5.11 servers. phpMyAdmin needs web server with PHP and MySQL database. This guide uses Apache web server with PHP 5.6 or Nginx web server with PHP 5.6 (PHP-FPM) and MySQL 5.6 database server or MariaDB 10/5.5 database server. You can also use your already installed versions of web server, PHP and MySQL.
If you want to install phpMyAdmin with Apache then use a – [Apache] sections and if you want install phpMyAdmin with Nginx then use b – [Nginx] sections.
MariaDB is a binary drop in replacement for MySQL database server. This means that for most cases, you can just uninstall MySQL and install MariaDB and you are good to go.
Why MariaDB? MariaDB is totally open source version of MySQL It works just like MySQL and is compatible with MySQL setups Fedora and Red Hat/CentOS/Rocky Linux use MariaDB instead of MySQL This is guide, **howto install or upgrade MariaDB 10.7.1 \[RC\], 10.6.3 \[stable\] or 10.5.13 \[stable\] on Fedora 35/34/33, CentOS Stream 8, Red Hat (RHEL) 8.5 and Rocky Linux 8.5**. Installing MariaDB is almost same process than [install MySQL](/2010/install-mysql-on-fedora-centos-red-hat-rhel/ "MySQL Install guide"). Note: If you are moving from MySQL, then make sure that you backup (dump and copy) your database and configs. And if upgrading from earlier versions, then remember run mysql_upgrade command. And if you uninstall MySQL, then remember restore /etc/my.cnf after installation, like: