{"id":2823,"date":"2025-06-03T06:32:47","date_gmt":"2025-06-03T06:32:47","guid":{"rendered":"https:\/\/www.dedicatedcore.com\/blog\/?p=2823"},"modified":"2025-06-04T06:26:53","modified_gmt":"2025-06-04T06:26:53","slug":"optimize-mysql-for-open-source-erp","status":"publish","type":"post","link":"https:\/\/www.dedicatedcore.com\/blog\/optimize-mysql-for-open-source-erp\/","title":{"rendered":"How to Optimize MySQL for Open-Source ERP on a VPS"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Open-source Enterprise Resource Planning (ERP) systems, such as ERPNext, Odoo, or Dolibarr, must continue to utilize MySQL (or its fork, MariaDB) in their operations to manage vital business data efficiently. Running an ERP on a VPS provides flexibility and cost-effectiveness, but the limited VPS resource availability calls for an optimized configuration of MySQL to ensure smooth functioning. A well-optimized MySQL installation can dramatically increase the speed, scale, and performance of your ERP so that your accounting, inventory, HR, and other functions work seamlessly. Transform your business operations with a detailed guide on <a href=\"https:\/\/www.dedicatedcore.com\/blog\/install-erpnext-ubuntu\/\" target=\"_blank\" rel=\"noopener\">ERPNext deployment on Ubuntu<\/a>, enabling streamlined setup, optimized performance, and secure configuration for your ERP system.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This article will provide an exhaustive approach for optimizing MySQL for a deployed open-source ERP on a VPS to meet the needs of both beginners and seasoned administrators. By placing your ERP on a high-performance VPS, such as those offered by DedicatedCore, you make use of SSD storage and scalable resources to enhance performance. The following will discuss why it must be optimized, system requirements, considerations to keep in mind before doing any optimization, detailed optimization steps, frequently asked questions, and other resources for an enhanced ERP environment.<\/span><\/p>\n<h4>Why It Is Important to Perform MySQL Optimization for ERP<\/h4>\n<p><span style=\"font-weight: 400;\">Optimizing MySQL for open source ERP installation in a VPS environment is critical for high transaction and query throughput generated by business operations. ERP systems involve a complex network of database interactions, and if left unoptimized, MySQL may result in prolonged response times, excessive server loads, and even server downtime. Fine-tuning specific MySQL configurations, indexing certain tables, and adhering to best practices can significantly improve query performance, conserve resources, and scale with your business needs. DedicatedCore will take this optimization one step further by providing a very reliable infrastructure for low latency and high availability.<\/span><\/p>\n<h3>Requirements<\/h3>\n<p><span style=\"font-weight: 400;\">To consider MySQL optimization for an open-source ERP deployment on a VPS, the following requirements are provided:<\/span><\/p>\n<h4>Operating System<\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Recommendation: Ubuntu 20.04 LTS or 22.04 LTS for stability and compatibility with MySQL\/MariaDB.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">System has to be kept updated: sudo apt update &amp;&amp; sudo apt upgrade -y.<\/span><\/li>\n<\/ul>\n<h4>Hardware<\/h4>\n<p><b>Minimum:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">CPU: Dual-core processor<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">RAM: 4 GB<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Storage: 40 GB SSD<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Network: 10 Mbps reliable connection<\/span><\/li>\n<\/ul>\n<p><b>Recommended (Better performance):<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">CPU: 4-core processor or above<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">RAM: 8 GB or more<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Storage: 100 GB SSD or higher<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Network: 100 Mbps or better<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">DedicatedCore&#8217;s VPS solutions provide adequately scalable CPU, RAM, and SSD storage for running resource-intensive ERP databases effectively.<\/span><\/p>\n<h4>Software<\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">MySQL\/MariaDB: 8.0 or higher for MySQL, or 10.5 or higher for MariaDB.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">ERP: Open-source ERP compatible with the above system (like ERPNext or Odoo).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Tools: MySQLTuner, sysbench, or Percona Toolkit for ranking performance testing.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Access: SSH access with sudo rights for configuring this.<\/span><\/li>\n<\/ul>\n<h4>Pre-Optimization Tips<\/h4>\n<p><span style=\"font-weight: 400;\">Prepare your VPS before optimizing MySQL to avoid any issues and have a smooth process:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Back Up Your Database:<\/b><span style=\"font-weight: 400;\"> Use mysqldump and back up all ERP databases (mysqldump -u root -p database_name &gt; backup.sql) just in case anything happens to the data.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Check Resources Usage:<\/b><span style=\"font-weight: 400;\"> Use htop\/iotop to monitor CPU, RAM, and Disk I\/O for bottlenecks.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Update MySQL:<\/b><span style=\"font-weight: 400;\"> The latest MySQL\/MariaDB version should be installed for any performance and security patches.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Use SSD Storage:<\/b><span style=\"font-weight: 400;\"> For the VPS, utilize storage based on SSDs (e.g., from DedicatedCore) for faster disk I\/O.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Allow Swap Space:<\/b><span style=\"font-weight: 400;\"> Configure swap (say 2-4 GB) to absorb any memory spikes on a low RAM VPS.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Secure MySQL:<\/b><span style=\"font-weight: 400;\"> Use mysql_secure_installation to set a root password and remove test databases.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Test Gradually:<\/b><span style=\"font-weight: 400;\"> Fine-tune one change at a time and watch its performance so that you may be able to identify problems.<\/span><\/li>\n<\/ol>\n<h2><b>Steps and Process<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Optimization of MySQL for an open-source ERP on a VPS involves tuning the configurations, creating indexes, and running maintenance. The steps should be followed in order:<\/span><\/p>\n<h3><b>Step 1: Analyze Current Performance<\/b><\/h3>\n<p>1. Install MySQLTuner to analyze the performance of MySQL:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo apt install -y mysqltuner\r\nmysqltuner<\/pre>\n<p><span style=\"font-weight: 400;\">Check recommendations about memory, caching, and queries provided from the output.<\/span><\/p>\n<h3>Step 2: Configure MySQL Settings<\/h3>\n<p>1. Edit the MySQL configuration file (either \/etc\/mysql\/my.cnf or \/etc\/my.cnf):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo nano \/etc\/mysql\/my.cnf<\/pre>\n<p>2. Under the [mysqld] section, add or update the following, keeping in mind your VPS&#8217;s resources (These settings are given for an 8 GB RAM VPS):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">[mysqld]\r\ninnodb_buffer_pool_size = 4G\u00a0 # 50-70% of RAM\r\ninnodb_log_file_size = 256M \u00a0 # 25% of buffer pool\r\nquery_cache_type = 0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # Disable for MySQL 8.0+\r\nquery_cache_size = 0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # Disable for MySQL 8.0+\r\ntmp_table_size = 64M\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # Temporary table size\r\nmax_connections = 100 \u00a0 \u00a0 \u00a0 \u00a0 # Adjust based on ERP load\r\ninnodb_file_per_table = 1 \u00a0 \u00a0 # Better space management\r\ncharacter-set-server = utf8mb4\r\ncollation-server = utf8mb4_unicode_ci<\/pre>\n<ol start=\"3\">\n<li><span style=\"font-weight: 400;\"> Restart MySQL to let the changes take effect:<\/span><\/li>\n<\/ol>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl restart mysql<\/pre>\n<h3>Step 3: Database Structure Optimization<\/h3>\n<p>1. Identify slow queries with MySQL slow query logs; whenever you do this, restart MySQL and then analyze the logs, either manually or with pt-query-digest.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo nano \/etc\/mysql\/my.cnf<\/pre>\n<p><span style=\"font-weight: 400;\">Add:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">[mysqld]\r\nslow_query_log = 1\r\nslow_query_log_file = \/var\/log\/mysql\/mysql-slow.log\r\nlong_query_time = 1<\/pre>\n<p><span style=\"font-weight: 400;\">2. Add indexes where appropriate for frequently queried tables, highlighted later:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CREATE INDEX idx_column_name ON table_name (column_name);<\/pre>\n<p><span style=\"font-weight: 400;\">Run EXPLAIN SELECT statements; for example, on queries with unindexed tables in your ERP database.<\/span><\/p>\n<h3>Step 4: Maintenance in General<\/h3>\n<p>1. Optimize tables so that free space will be reclaimed, which ensures that it will also perform better.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">OPTIMIZE TABLE table_name;<\/pre>\n<p>2. Schedule backups regularly with mysqldump or other tools, such as cron.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">crontab -e\r\n0 2 * * * mysqldump -u root -p'your_password' database_name &gt; \/backups\/erp_backup_$(date +\\%F).sql<\/pre>\n<p>3. Monitor performance using top or DedicatedCore&#8217;s server monitoring dashboard.<\/p>\n<h3>Step 5: Enable Caching<\/h3>\n<p>1. Install Redis and configure it for query caching (if the ERP supports it):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo apt install -y redis-server<\/pre>\n<p><span style=\"font-weight: 400;\">2. Configure the ERP to use Redis for session and query caching to reduce MySQL load.<\/span><\/p>\n<h3>Step 6: Test and Monitor<\/h3>\n<p>1. Run sysbench to simulate ERP workload:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sysbench --db-driver=mysql --mysql-user=root --mysql-password=your_password --mysql-db=erp_database --table-size=1000000 oltp_read_write run<\/pre>\n<ol start=\"2\">\n<li><span style=\"font-weight: 400;\">Monitor MySQL performance via SHOW STATUS LIKE &#8216;Innodb%&#8217;; to see buffer pool usage and I\/O.<\/span><\/li>\n<\/ol>\n<h4>Frequently Asked Questions (FAQ)<\/h4>\n<p><b>1. How can I determine the ideal innodb_buffer_pool_size for my VPS?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Calculate the innodb_buffer_pool_size to be around 50-70% of your VPS RAM, leaving enough for the OS plus ERP processes. For an 8 GB RAM VPS, it comes to something between 4 and 5 GB. Also, use MySQLTuner to check whether the setting follows your ERP&#8217;s query pattern and change them if disk I\/O is largely high.<\/span><\/p>\n<p><b>2. What makes ERP queries slow even after optimization?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Lack of indexing, huge data sets, or unfit hardware can be reasons for inefficient queries. Try the EXPLAIN command to track query execution plans and add indexing wherever needed. If performance continues to degrade, consider buying the DedicatedCore VPS oriented with more CPU and RAM.<\/span><\/p>\n<p><b>3. Should I use MariaDB instead of MySQL for my ERP?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Yes, MariaDB is a drop-in substitute for MySQL and is compatible with most open-source ERPs. It also performs nearly the same, sometimes with a few extra features. Your ERP must be compatible with the version of MariaDB that you are installing (e.g., 10.5 or higher).<\/span><\/p>\n<h4>Resources<\/h4>\n<ol>\n<li><span style=\"font-weight: 400;\"><strong>MySQL Official Documentation<\/strong><br \/>\n<\/span>In-depth guides on tuning, indexing, and performance enhancement of MySQL.<br \/>\nURL: https:\/\/dev.mysql.com\/doc\/<\/li>\n<li><span style=\"font-weight: 400;\">\u00a0<strong>MariaDB Knowledge Base<\/strong><br \/>\n<\/span>Complete documentation to configure and optimize MariaDB for ERP systems.<br \/>\nURL: https:\/\/mariadb.com\/kb\/en\/documentation\/<\/li>\n<li><strong>ERPNext Documentation<\/strong><br \/>\nERPNext specific database optimization guide, including MySQL settings.<br \/>\nURL: https:\/\/docs.erpnext.com<\/li>\n<li><strong>Percona Toolkit<\/strong><br \/>\nA set of tools for performance analysis and query optimization for MySQL.<br \/>\nURL: https:\/\/www.percona.com\/software\/mysql-tools\/percona-toolkit<\/li>\n<li><strong>DedicatedCore VPS Hosting<\/strong><br \/>\nHigh-performance VPS solutions with scalable resources and SSD storage for ERP databases.<br \/>\nURL: https:\/\/www.dedicatedcore.com<\/li>\n<\/ol>\n<h4>Final Words on Optimizing MySQL for Open-Source ERP on a VPS<\/h4>\n<p><span style=\"font-weight: 400;\">MySQL optimization for an open-source ERP on the VPS is an important step in speeding up, enabling, and scaling business operations. If you follow the instructions in this article, your database should be tuned, your ERP should perform better, and the resource contention should become minimal.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">With a dedicated VPS solution from DedicatedCore, an ERP system is provided with very high-speed infrastructure so that the business can flourish. Start optimizing now to give your ERP full functionality.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Open-source Enterprise Resource Planning (ERP) systems, such as ERPNext, Odoo, or Dolibarr, must continue to utilize MySQL (or its fork, MariaDB) in their operations to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2832,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/2823"}],"collection":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/comments?post=2823"}],"version-history":[{"count":10,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/2823\/revisions"}],"predecessor-version":[{"id":2837,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/2823\/revisions\/2837"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/media\/2832"}],"wp:attachment":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/media?parent=2823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/categories?post=2823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/tags?post=2823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}