Database Archives - ScriptsTown https://scriptstown.com/category/database/ Tutorials, Themes & Plugins Thu, 25 Dec 2025 07:18:35 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 https://scriptstown.com/wp-content/uploads/2023/11/cropped-ScriptsTown-32x32.png Database Archives - ScriptsTown https://scriptstown.com/category/database/ 32 32 How to Upgrade MariaDB Server to a Newer Version in Ubuntu https://scriptstown.com/how-to-upgrade-mariadb-server-to-a-newer-version-in-ubuntu/ Sat, 19 Aug 2023 19:27:59 +0000 https://scriptstown.com/?p=4286 In this guide, you will learn how to safely upgrade the MariaDB database server to a newer version in the Ubuntu Linux distribution. Also, you will know how to check current MariaDB packages and remove the older version after upgrading the MariaDB server. Create Hosting Server Backup First of all, it’s important to create a [...]

The post How to Upgrade MariaDB Server to a Newer Version in Ubuntu appeared first on ScriptsTown.

]]>
In this guide, you will learn how to safely upgrade the MariaDB database server to a newer version in the Ubuntu Linux distribution. Also, you will know how to check current MariaDB packages and remove the older version after upgrading the MariaDB server.

Create Hosting Server Backup

First of all, it’s important to create a full backup of your server or website in order to restore it in case something goes wrong. You can use snapshots or any of your preferred methods to create a full backup of your hosting server. After creating the backup, you can proceed with the upgradation process of the MariaDB server by following the steps below.

Check MariaDB Version and Repository Sources

To be able to update MariaDB, log in to your SSH terminal with a user having sudo privilege so we can run commands.

First, you can check the current version of MariaDB with this command:

> mariadb --version

You can also use this command to check the version of MariaDB:

> dpkg -l | grep mariadb

The above command lists all installed software packages and filters for those that contain “mariadb” in their name. This helps to identify any installed MariaDB packages. Also, it mentions the version of the installed package.

Next, run the following command to check the repository sources. Here, check the source list to identify if there’s any source repository with MariaDB listed there. Most commonly, it would be something like “/etc/apt/sources.list.d/mariadb.list”. If it already exists, then we can change it to a new version. And, if it doesn’t exist then we can add it with a new version.

> grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*

After, we would need to add MariaDB with a new version in the repository source if it doesn’t exist already. Also, we may just need to change the version of the MariaDB server if it already exists in the source repository list.

Add MariaDB with New Version in Repository Source

Suppose your current version of MariaDB is 10.6 and you want to upgrade it to version 11.4.

If you already see an existing package in the repository source with a name like “mariadb.list” using the previous “grep” command and you see its current version as 10.6. Then, to change it from version 10.6 to 11.4, you would use the following command:

> sudo sed -i 's/10.6/11.4/' /etc/apt/sources.list.d/mariadb.list

In case you can’t find any repository source with “mariadb” in it, then to add it for version 11.4, you can run the command:

> sudo curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-11.4"

The above command would add a new repository source for any relevant MariaDB 11.4 packages that we can install or upgrade to. You can verify the repository source list again to check if it now adds “mariadb.list” to the source list using the command:

> grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*

Upgrade MariaDB to New Specified Version

Once, you are sure that the “mariadb.list” exists in the repository source, then you can run the following command to update the package list by fetching the latest information about available software and updates from the software repositories.

> sudo apt update

Now, we are ready to perform the actual upgrade of the MariaDB database server.

First, we need to stop the running “mariadb” service using the command:

> sudo systemctl stop mariadb

Next, run the following command to do the upgrade, it will specify which packages it would add, change, or remove after the upgrade, you can confirm with “Y”:

> sudo apt install --only-upgrade mariadb-server
Y

After, run the command to remove packages that it won’t need anymore and confirm:

> sudo apt autoremove
Y

Once the upgradation process is finished, we would need to reload the daemon process. This ensures that the system recognizes and applies any changes in the MariaDB service configuration. It allows the upgraded database to function correctly with the newly updated settings without needing a full system restart.

> sudo systemctl daemon-reload

Also, you can start the “mariadb” service with this command:

> sudo systemctl start mariadb

Finally, we can run the “mariadb-upgrade” command to ensure that your MariaDB database functions properly after an upgrade by making necessary adjustments and fixing any compatibility issues that might arise.

It upgrades system tables, performance schema, INFORMATION_SCHEMA, and sys schema. Also, it examines user schemas to ensure compatibility and take advantage of new features.

> sudo mariadb-upgrade

Note that you may also run “mysql_upgrade” in place of “mariadb-upgrade” in case it doesn’t work:

> sudo mysql_upgrade

In case, it throws an error “Access denied for user ‘root’@’localhost'”, then you can provide the MariaDB root user password in the command as follows:

> sudo mariadb-upgrade -u root -p

Or, by using “mysql_upgrade”:

> sudo mysql_upgrade -u root -p

You may also force the check for any incompatibilities with the upgraded MariaDB server with any one of these commands:

> sudo mariadb-upgrade --force
> sudo mysql_upgrade --force
> sudo mariadb-upgrade -u root -p --force
> sudo mysql_upgrade -u root -p --force

Confirm the New Version of MariaDB

Now, to confirm the new version, you can use the command to list installed MariaDB packages with version information:

> dpkg -l | grep mariadb

Remove the Old Version of MariaDB and Cleanup

You may see older packages of MariaDB when you run the above “dpkg” command. You can remove those old packages by using their names as follows:

> sudo apt purge mariadb-server-10.6 mariadb-client-10.6
Y

Again, you can confirm the MariaDB packages and the older packages should not be there anymore.

> sudo dpkg -l | grep mariadb

So, now you have the newer version of MariaDB without any residual packages.

In conclusion, upgrading MariaDB to a newer version brings performance improvements, security enhancements, new features, bug fixes, and long-term support. It’s always crucial to create a full backup of your hosting server before doing upgrades like this. There are several steps to follow when you want to upgrade MariaDB to the latest version.

We also have a step-by-step, easy-to-follow guide on how to reset MySQL root password and this guide works for the MariaDB database server as well.

The post How to Upgrade MariaDB Server to a Newer Version in Ubuntu appeared first on ScriptsTown.

]]>
How to Use Object Cache with Redis to Reduce WordPress Load https://scriptstown.com/how-to-use-object-cache-with-redis-to-reduce-wordpress-load/ Thu, 13 Apr 2023 20:25:49 +0000 https://scriptstown.com/?p=3994 Object cache with Redis can minimize the load on your WordPress database by caching frequently accessed data in memory instead of having to retrieve it from the database every time it’s needed. This can significantly reduce the number of database queries required to load a page, resulting in faster page load times and reduced server [...]

The post How to Use Object Cache with Redis to Reduce WordPress Load appeared first on ScriptsTown.

]]>

Object cache with Redis can minimize the load on your WordPress database by caching frequently accessed data in memory instead of having to retrieve it from the database every time it’s needed. This can significantly reduce the number of database queries required to load a page, resulting in faster page load times and reduced server load.

By reducing the load on your WordPress database, you can also improve the overall performance and scalability of your WordPress site.

In this guide, we learn how to use object cache in Redis in WordPress using a drop-in plugin. Also, we learn the steps to install the Redis server and how to monitor its memory usage.

Installing and Configuring Object Cache Drop-in Plugin

Instead of installing Redis plugin from a WordPress repository, we can install a drop-in plugin.

A drop-in plugin is a PHP file that you can drop into the WordPress “wp-content” directory. This automatically activates the plugin without any additional configuration or settings.

To get WordPress Redis drop-in plugin, navigate to its GitHub repository, and click on the “Code” > “Download ZIP”. Next, extract the zip, you will find a PHP file “object-cache.php”. This is a drop-in WordPress plugin for enabling object cache with Redis.

Setting Default Expiration Time for Redis

Now, before installing this drop-in plugin, you can edit it and set Redis default expiration time by editing the “object-cache.php” file. You will see this line of code:

if ( ! defined( 'WP_REDIS_DEFAULT_EXPIRE_SECONDS' ) ) {
	define( 'WP_REDIS_DEFAULT_EXPIRE_SECONDS', 0 );
}

You can change the value of 0 (which means no expiration) to something like 604800 (which is 7 days). So, it will look like this:

if ( ! defined( 'WP_REDIS_DEFAULT_EXPIRE_SECONDS' ) ) {
	define( 'WP_REDIS_DEFAULT_EXPIRE_SECONDS', 604800 );
}

Setting an appropriate expiration time for cached data ensures that stale data is not being served to site visitors. Additionally, it helps to prevent the Redis cache from becoming too large and overwhelming the server’s resources.

However, there are other methods to prevent excessive memory usage by Redis that are mentioned in this guide below.

Once, you have finished editing the “object-cache.php” file, you can install it as a drop-in plugin on your WordPress site.

Installing Redis Object Cache Drop-in Plugin

Using your WordPress file manager, you can simply put “object-cache.php” inside the “wp-content” directory. So, it will look like “wp-content/object-cache.php”.

Now, in your WordPress admin panel, you can check this drop-in plugin by going to “Plugins” > “Installed Plugins” > “Drop-in”.

Next, you would need to mention the Redis server host, port, and Redis database to use for your WordPress website inside the “wp-config.php” file. You can do so by going to your WordPress file manager, then edit your “wp-config.php” file, and adding the following code just above the message as shown below:

// Redis.
$redis_server = array(
	'host'     => '127.0.0.1',
	'port'     => 6379,
	'auth'     => '',
	'database' => 0,
);

/* That's all, stop editing! Happy publishing. */

You can use database values such as 0, 1, 2, and so on depending on the specific WordPress website in case there are multiple WordPress sites on the same server.

WP Redis: Connection Attempt Failed

After installing the drop-in Redis plugin, if you see a message like “WP Redis: A connection attempt failed”, then it means Redis is not installed on your server. Below are the steps to install Redis and its PHP extension on a server.

Installing Redis Server and PHP Redis Extension

First, you need to log in to your server via SSH (terminal). To check if Redis is already installed on your server, you can check this by using the command:

> redis-cli info

If Redis is already installed, you should get information about the Redis service, else you will get the command not found message.

If it shows command not found, then install Redis by running these commands one by one:

> sudo apt-get update
> sudo apt-get install redis-server

Next, press Y to continue installing Redis and its related packages. Now, you can re-run the “redis-cli info” command and it should return some output.

The drop-in plugin also requires a PHP Redis extension. You can enable this extension by going to your cPanel PHP settings. Or, you can install it using the SSH terminal of your server.

Enable PHP Redis Extension via cPanel

If you use a cPanel for managing server configurations, there you can enable the PHP Redis extension by going to your cPanel’s PHP settings.

Depending on the PHP version that your WordPress site runs on, you would need to enable the PHP Redis extension that corresponds to the PHP version.

Install PHP Redis Extension via SSH

If the PHP Redis extension is not installed, then you can install it via SSH terminal using the following command:

> sudo apt-get install php8.3-redis

You can adjust the above command to install the PHP Redis extension for the PHP version that your WordPress site uses.

Setup Maximum Memory Limit and Policy for Redis

It’s good to set a maximum memory limit for a Redis so it does not run out of memory. Therefore, it won’t throw any memory-related errors. To set the maximum memory limit for Redis, you can SSH on your server and run the command to edit the Redis configuration file:

> sudo nano /etc/redis/redis.conf

Set Maximum Memory Value

Next, in the “redis.conf” file, using the nano editor, use the “Ctrl + W” key to search for “maxmemory <bytes>”. You will see this line:

# maxmemory <bytes>

Remove the “#” and change the above line to add maximum memory, so it will look like this:

maxmemory 100mb

The value “100mb” depends on the size of your actual WordPress database as well as how frequently data is accessed, you can experiment with it by setting a small value first like “40mb”, “60mb”, and so on, then you can monitor Redis memory usage and change its value depending on the Redis memory usage.

Save the file with “Ctrl + X” and then “Y”. Then, restart Redis using the command:

> sudo systemctl restart redis.service

Set Policy for Maximum Memory

It is also necessary to set a policy for evicting keys once maximum memory usage is reached by the Redis instance, you can do so by the editing Redis configuration just like above:

> sudo nano /etc/redis/redis.conf

Using “Ctrl + W”, search for “maxmemory-policy noeviction”, then you will find this line:

# maxmemory-policy noeviction

Remove the “#” and change it so, it will look like this:

maxmemory-policy volatile-lru

You may also change it to “allkeys-lru” instead of “volatile-lru”.

maxmemory-policy allkeys-lru

The “allkeys-lru” value evicts the least recently used keys from the Redis cache.

The “volatile-lru” value only considers volatile keys when evicting items from the cache. Volatile keys are those that have an expiration time set, so they will be automatically deleted from the cache when that time is reached.

Save the file with “Ctrl + X” and then “Y”.

After making changes to the Redis configuration, you must restart the Redis service by running the following command:

> sudo systemctl restart redis.service

Monitoring Redis Memory Usage

There are many useful Redis commands to check Redis keyspace and its memory usage.

To check the current memory usage of Redis, use the command:

> redis-cli info memory

This will display a lot of information related to memory usage.

See only the used memory and memory overhead of Redis using the command:

> redis-cli info memory | grep 'used_memory'

Display the current memory usage of Redis in a human-readable format:

> redis-cli info memory | grep 'used_memory.*human';

You can also check the memory usage of individual Redis databases with the command:

> redis-cli info keyspace

This will show the memory usage of each database in bytes.

You may also want to clear all cache in the Redis memory:

> redis-cli FLUSHALL

For clearing individual Redis databases like 0, you can run the following command:

> redis-cli -n 0 FLUSHDB

In conclusion, using an object cache with Redis can significantly reduce the load time of WordPress websites. By storing frequently accessed data in memory, object cache like Redis can reduce the number of database requests and improve site performance.

To use object cache with Redis in WordPress, users have to install and configure Redis, enable the PHP Redis extension, install a Redis object cache plugin, and add Redis configuration settings to the WordPress configuration file.

The post How to Use Object Cache with Redis to Reduce WordPress Load appeared first on ScriptsTown.

]]>
Top Open Source Web Control Panel for VPS WordPress Hosting https://scriptstown.com/top-open-source-web-control-panel-for-vps-wordpress-hosting/ Mon, 27 Mar 2023 04:31:53 +0000 https://scriptstown.com/?p=3960 In this article, we explore the top open-source web control panel for VPS WordPress hosting. All of these web control panels offer server administrators and website owners an easy way to manage their servers and websites. With the help of these web control panels, users can easily configure their servers, manage domains, databases, and web [...]

The post Top Open Source Web Control Panel for VPS WordPress Hosting appeared first on ScriptsTown.

]]>
In this article, we explore the top open-source web control panel for VPS WordPress hosting. All of these web control panels offer server administrators and website owners an easy way to manage their servers and websites.

With the help of these web control panels, users can easily configure their servers, manage domains, databases, and web applications, and monitor their server’s performance.

Hestia Control Panel

Hestia Control Panel is a fast, open-source control panel forked from VestaCP, built around a clean interface and the essential features most small-to-medium server admins need. It uses NGINX as the front/proxy with optional Apache backend support, provides one-click app installs via the UI or CLI, and supports multiple PHP versions.

On the security side, Hestia includes per-domain TLS, SFTP and SSH chroot jails, SSH-key login, and two-factor authentication for the admin UI.

Hestia includes a full mail stack (Exim/Dovecot with Roundcube or SnappyMail), built-in DNS with DNSSEC support, and automated backups to SFTP/FTP or cloud targets via rclone. The panel also provides fine-grained user accounts (share access and limit resources) so you can safely share server access.

In summary, Hestia Control Panel makes it easy to host multiple domains, mailboxes, and databases from one place. It is straightforward, lightweight, and built for admins who want full control with low overhead.

CyberPanel

CyberPanel is a popular open-source web hosting control panel that is designed for speed and security. It supports OpenLiteSpeed, which is faster than Apache and Nginx in general. Also, it has built-in support for LiteSpeed Cache to greatly improve website performance.

CyberPanel supports multiple PHP versions and offers built-in support for popular web applications like WordPress. It is easy to install and it is compatible with popular VPS providers such as DigitalOcean, Linode, Vultr, and Amazon Lightsail.

It offers user-friendly interface and comes with various features, including one-click backups, automatic SSL installation, and DNS management.

We have a guide on how to install WordPress on CyberPanel that you may want to check.

Virtualmin

Virtualmin is a sophisticated web hosting control panel tailored for Linux systems, offering robust solutions for web developers, IT professionals, and hosting providers. It supports major Linux distributions, including Debian, Ubuntu, Rocky Linux, AlmaLinux, and RHEL.

Available as an open-source GPL version, Virtualmin provides a user-friendly platform for managing server security, deploying web applications like WordPress, ClassicPress, Django, Joomla, Drupal, phpMyAdmin, etc. and handling website management tasks with ease.

Built as a module on top of Webmin, Virtualmin allows users to manage DNS, mailboxes, and databases. It offers fine-grained access control with support for domain owner and reseller accounts. Its security features include two-factor authentication, brute force protection, and SSL certificate management via Let’s Encrypt.

For hosting providers and developers, Virtualmin integrates seamlessly with cloud services such as Dropbox, Google Drive, and Amazon S3 for backups and migrations. Virtualmin complements its browser-based interface with comprehensive command-line access. It supports interactive terminal access for advanced server management.

Virtualmin’s extensibility and flexibility make it a favorite among system administrators. Its modular architecture allows for the creation of custom modules and themes, scripting for automation, and the use of server templates to meet unique needs. It offers compatibility with external services like Cloudflare and Amazon Route 53 for DNS management.

Webmin

Webmin is a highly popular open-source web control panel that has been around for a long time. It is compatible with Linux, Unix, and Windows operating systems. It provides a user-friendly interface that makes it easy to manage servers and websites.

Webmin comes with several features, including file management, DNS management, Apache and Nginx configuration, and package management. It is highly customizable, and users can install additional modules to extend its functionality. With Webmin, users can also configure operating system internals, as well as manage user accounts and disk quotas.

Vesta Control Panel

Vesta Control Panel is a lightweight and easy-to-use open-source web control panel that is designed for VPS hosting. It’s compatible with Linux operating systems.

VestaCP comes with various features, including Apache and Nginx configuration, DNS management, and backup and restore options. It offers a simple and intuitive interface that allows users to manage domains, websites, databases, and emails. Also, it has a built-in firewall that enhances website security.

Control Web Panel

Control Web Panel (CWP) is a feature-rich, open-source web control panel that is designed for CentOS and Red Hat Enterprise Linux (RHEL) servers. It’s compatible with both Apache and Nginx web servers and comes with features like DNS management, file management, user management, and email handling, with options for internal or external mail routing. It also includes firewall, backup, restore, and SSL management.

CWP requires minimal server resources and can run on a server with as little as 512 MB of RAM. It is easy to set up and has an active community to provide support and updates.

Ajenti Panel

Ajenti is a lightweight, open-source web control panel that supports multiple operating systems, including Ubuntu, Debian, CentOS, and RHEL. Its efficient design results in minimal resource usage, making it suitable for deployment on low-end machines. It’s compatible with both Apache and Nginx web servers and comes with various features like file management, DNS configuration, email management, and backup and restore options.

Ajenti is highly customizable, and due to its modular design, users can install additional plugins in order to extend its functionality.

ISPConfig Control Panel

ISPConfig is a free and open-source web control panel that is designed for Linux servers. It supports both Apache and Nginx web servers and comes with various features, including DNS management, email accounts, FTP users, and databases.

ISPConfig offers a comprehensive backup system with the ability to automate backups and restore data directly from the control panel. It provides multiple authentication methods, including LDAP, MySQL, and OpenID for secure access control. Its multiserver and clustering capabilities allow administrators to manage one or more servers from a single control panel.

Its multilingual interface caters to a global user base, and its extensive documentation and active community ensure reliable support and updates.

Summary

In summary, open-source web control panels can greatly simplify server management for your VPS WordPress hosting. Whether you’re looking for a user-friendly interface, reliability, customization options, or an active community for support, there is a web control panel out there that can meet your needs.

By taking the time to research and choose the right web control panel, you can ensure efficient server management and a smooth WordPress hosting experience.

Here’s a simplified comparison in a tabular format:

Control PanelServer SupportUsabilityPerformanceScalabilityResource Usage
HestiaNginx, ApacheEasyFastModerateLow
CyberPanelOpenLiteSpeedEasyFastHighLow
VirtualminApache, NginxModerateModerateHighLow
WebminApache, NginxModerateModerateModerateLow
VestaCPApache, NginxEasyFastHighLow
Control Web PanelApache, NginxModerateModerateModerateModerate
AjentiAny serverEasyFastHighLow
ISPConfigApache, NginxModerateModerateModerateModerate
Comparison of Open-Source Web Control Panels

Bonus: Free Web Control Panel(s) (Not Open Source)

CloudPanel (Not Open Source)

CloudPanel is a modern, cloud-focused control panel built for simplicity, performance and security. It supports hosting of static sites, PHP, Node.js and Python applications in fully isolated site environments.

CloudPanel ships with an installation wizard that handles site creation and Let’s Encrypt certificates, and enforces site isolation, UFW firewall management, IP and bot blocking, and basic auth for development staging, and a compact management UI that’s optimised for cloud VPS/workloads.

In short, CloudPanel provides optimized defaults and compact tooling so teams can deploy mixed workloads quickly while keeping resource use low and performance high. It markets itself as free and built for performance; however, its license terms show it’s distributed under license terms controlled by the vendor and includes open-source components.

The post Top Open Source Web Control Panel for VPS WordPress Hosting appeared first on ScriptsTown.

]]>
How to Install MariaDB on Ubuntu & Create Database https://scriptstown.com/how-to-install-mariadb-on-ubuntu-create-database/ Mon, 22 Apr 2019 19:13:18 +0000 https://scriptstown.com/?p=47 MariaDB server is one of the most popular and open-source relational database servers in the world. It is backward-compatible and a replacement for MySQL. In this guide, you will learn how to install the MariaDB server on Ubuntu 20.04 or later. First of all, you need to log in as a sudo user. Then, use [...]

The post How to Install MariaDB on Ubuntu & Create Database appeared first on ScriptsTown.

]]>
MariaDB server is one of the most popular and open-source relational database servers in the world. It is backward-compatible and a replacement for MySQL. In this guide, you will learn how to install the MariaDB server on Ubuntu 20.04 or later.

First of all, you need to log in as a sudo user. Then, use the following command to install the MariaDB server:

> sudo apt install mariadb-server

Next, you can use the following command to check if the MariaDB service is enabled at system startup.

> sudo systemctl status mariadb

If it is not enabled at system startup, then you can enable it using the command:

> sudo systemctl enable mariadb

Also, you can start the service with this command:

> sudo systemctl start mariadb

Securing MariaDB Server

After installation, to secure it, you can run the following command:

> sudo mysql_secure_installation

Or, you may use this command (instead of underscores, there are dashes):

> sudo mariadb-secure-installation

Note that, “mariadb-secure-installation” is a symlink to “mysql_secure_installation” from MariaDB 10.4.6. This means, they would work the same and you can use any one of them. The command “sudo mariadb-secure-installation” would work for version 10.4.6 or later.

In order to log into MariaDB to secure it, you’ll need to enter the current password for the root user. If you’ve just installed the MariaDB server, and you haven’t set the root password yet, the password will be blank, so you can just press “Enter” here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.

You already have a root password set, so you can safely answer 'n' or you can press 'y' to change it.

Change the root password? [Y/n] n
 ... skipping.

By default, the installation has an anonymous user which allows anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing. You can remove them before moving into a production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, the root should only be allowed to connect from “localhost”. This ensures that someone cannot guess the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named “test” that anyone can access. This is also intended only for testing and should be removed before going into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Now, reload the privilege tables so, the changes can take place their effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!


Cleaning up...


All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Creating Database & Assign Users

In order to log into the MariaDB server to run SQL commands, you can run the command:

> sudo mariadb

Starting from version 11.0, the command “sudo mysql” would show a warning of “deprecated program name”. So, you can simply use “sudo mariadb” instead. Also, you can replace “mysql” with “mariadb” in most of the deprecated commands.

If the above command doesn’t work, then you can run this command instead:

> sudo mariadb -u root -p

Here, you will need to enter the MySQL or MariaDB root password. Once, you are logged into MariaDB, you can run the following command to create a database with a character set (optionally).

> mariadb> CREATE DATABASE exampledb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Here, the database name is “exampledb”. Now, to show all the databases, you can run this command:

> mariadb> show databases;

To create a new database user and grant all permissions of this database (“exampledb”) to that user, you can use the command:

> mariadb> GRANT ALL PRIVILEGES ON exampledb.* TO "exampledbuser"@"localhost" IDENTIFIED BY "your_password";

Here, “exampledbuser” is the new user, and the password for that user is “your_password”. Also, you can simply assign an existing user “testdbuser” to this new database “exampledb” using the following command:

> mariadb> GRANT ALL PRIVILEGES ON exampledb.* TO "testdbuser"@"localhost";

Now, you will need to flush the privileges for changes to take effect.

> mariadb> FLUSH PRIVILEGES;

Finally, you can exit from MariaDB mode using the “exit” command:

> mariadb> exit;

Benefits of MariaDB Database Server

Here are some great benefits of using MariaDB as your database server.

  • Improved caching and performance: It comes with enhanced caching mechanisms, resulting in faster query execution and overall better performance.
  • Tighter security measures: It provides internal security and password checks, PAM and LDAP authentication, user roles, and encryption, ensuring better data protection.
  • More storage engines: It offers a wider range of storage engines, including NoSQL support with Cassandra, allowing you to run SQL and NoSQL in a single database.
  • Galera cluster integration: It includes built-in support for the Galera cluster, providing synchronous multi-master replication for high availability and scalability.
  • Replication enhancements: It offers replication features like parallel replication, multi-source replication, and delayed replication, improving data redundancy and availability.
  • Open-source and free: You can use it for free and benefit from ongoing community contributions and updates, ensuring continuous improvement of the database system.
  • Monitoring capabilities: It offers advanced monitoring tools and features, allowing you to efficiently monitor and optimize the performance of your database.

In conclusion, the MariaDB server is a widely-used open-source relational database server and a popular replacement for MySQL. By following the steps outlined in this guide, you can easily install it and start building robust and scalable applications.

We also have a guide on how to upgrade MariaDB to a newer version.

It’s important to always back up your entire server before performing critical upgrades or installations. Many hosting providers offer built-in backup or snapshot features tailored to specific use cases. For example, there could be a managed hosting for WordPress, a VPS optimized for WooCommerce, or a dedicated server hosting for Magento 2.

The post How to Install MariaDB on Ubuntu & Create Database appeared first on ScriptsTown.

]]>