<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Archiwa MySQL - soban</title>
	<atom:link href="https://soban.pl/category/mysql-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://soban.pl/category/mysql-en/</link>
	<description>IT, Linux, Servers, Security</description>
	<lastBuildDate>Thu, 07 Nov 2024 15:22:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Resolving performance_schema Issues in MySQL</title>
		<link>https://soban.pl/resolving-performance_schema-issues-in-mysql-a-step-by-step-guide/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 07 Nov 2024 12:06:34 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=504</guid>

					<description><![CDATA[<p>During daily work with MySQL databases, specific challenges such as missing tables or errors related to the unrecognized database performance_schema can arise. These problems can significantly affect the performance and stability of database systems, and their diagnosis and resolution can often be complicated and time-consuming. To facilitate this task, I have created this guide, which [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/resolving-performance_schema-issues-in-mysql-a-step-by-step-guide/">Resolving performance_schema Issues in MySQL</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1021" height="1024" src="https://soban.pl/wp-content/uploads/2024/11/performance_schema_mysql-1021x1024.jpg" alt="" class="wp-image-505" srcset="https://soban.pl/wp-content/uploads/2024/11/performance_schema_mysql-1021x1024.jpg 1021w, https://soban.pl/wp-content/uploads/2024/11/performance_schema_mysql-300x300.jpg 300w, https://soban.pl/wp-content/uploads/2024/11/performance_schema_mysql-150x150.jpg 150w, https://soban.pl/wp-content/uploads/2024/11/performance_schema_mysql-768x770.jpg 768w, https://soban.pl/wp-content/uploads/2024/11/performance_schema_mysql.jpg 1136w" sizes="(max-width: 1021px) 100vw, 1021px" /></figure>



<p><br>During daily work with MySQL databases, specific challenges such as missing tables or errors related to the unrecognized database <code>performance_schema</code> can arise. These problems can significantly affect the performance and stability of database systems, and their diagnosis and resolution can often be complicated and time-consuming. To facilitate this task, I have created this guide, which is the result of my experiences and proven practices. I provide a comprehensive approach to identifying and fixing issues related to <code>performance_schema</code>. It&#8217;s quite simple to import the schema from a newly built database.<br><br>Of course, it&#8217;s best to perform a backup of the database before the entire operation.</p>



<h3 class="wp-block-heading">Initial Diagnosis in MySQL</h3>



<p>Start by identifying the problem in the MySQL shell:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">SHOW VARIABLES LIKE 'default_storage_engine';
ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist
USE performance_schema;
ERROR 1049 (42000): Unknown database 'performance_schema';</pre></div>



<h3 class="wp-block-heading">Creating New Performance Schema in MySQL</h3>



<p>Create a new performance schema from the MySQL command line:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">CREATE DATABASE performance_schema;
shutdown;
\q</pre></div>



<h3 class="wp-block-heading">Server Operations to Establish New MySQL Environment</h3>



<p>Return to the system to configure a clean MySQL environment:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl stop mysql.service
mkdir /var/lib/mysql_new
mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql_new
chown -R mysql:mysql /var/lib/mysql_new
cd /var/lib/mysql_new</pre></div>



<p>Then, start MySQL in safe mode to configure it &#8211; without external network interruptions:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">sudo -u mysql mysqld_safe --datadir=/var/lib/mysql_new --skip-grant-tables --skip-networking</pre></div>



<h3 class="wp-block-heading">Configuration and Verification in MySQL</h3>



<p>Return to the MySQL command line to verify the configuration and configure the new database:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">mysql -u root
SHOW DATABASES;
USE performance_schema;
SHOW TABLES;</pre></div>



<p>As you can see, here performance_schema is working correctly.<br>Update the root password in the MySQL environment to secure the new installation:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">USE mysql;
UPDATE user SET authentication_string=PASSWORD('NewSecurePassword');
FLUSH PRIVILEGES;
shutdown;
\q</pre></div>



<p>Restart MySQL in safe mode to ensure all configurations are applied:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">sudo -u mysql mysqld_safe --datadir=/var/lib/mysql_new --skip-networking</pre></div>



<h3 class="wp-block-heading">Configure MySQL Server to Run New Database</h3>



<p>After securing the new MySQL configuration, update the server configuration to use the new data directory:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">vi /etc/mysql/my.cnf
# Change datadir to:
datadir=/var/lib/mysql_new</pre></div>



<p>Restart the MySQL service to load the my.cnf file during mysql startup:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl start mysql.service</pre></div>



<h3 class="wp-block-heading">Export and Restore Performance Schema in MySQL</h3>



<p>With the new configuration, export <code>performance_schema</code> using MySQL commands and prepare for its restoration:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">mysqldump -u root -p --no-data --skip-lock-tables performance_schema &gt; /root/performance_schema.sql</pre></div>



<p>It&#8217;s necessary to shut down MySQL:<br></p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">shutdown;
\q</pre></div>



<p>Restore the original MySQL data directory on the server, restart the MySQL service, and import the exported schema:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">vi /etc/mysql/my.cnf
# Change datadir back to:
datadir=/var/lib/mysql_old
systemctl start mysql.service
mysql -u root -p performance_schema &lt; /root/performance_schema.sql
systemctl restart mysql.service</pre></div>



<p>Make sure the default storage engine is running, e.g:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">SHOW VARIABLES LIKE 'default_storage_engine';
+------------------------+--------+
| Variable_name          | Value  |
+------------------------+--------+
| default_storage_engine | InnoDB |
+------------------------+--------+
1 row in set (0.00 sec)</pre></div>



<div class="wp-block-urvanov-syntax-highlighter-code-block"></div>



<p><p>Don&#8217;t forget to remove the trash:</p></p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">rm -rf /var/lib/mysql_new/ /root/performance_schema.sql</pre></div>



<p>If you&#8217;ve reached this point, remember to delete the database backup &#8211; as long as everything is working. You did make one, right? 🙂<br></p>
<p>Artykuł <a href="https://soban.pl/resolving-performance_schema-issues-in-mysql-a-step-by-step-guide/">Resolving performance_schema Issues in MySQL</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MySQL Troubleshooting – ErrorCode: 1114</title>
		<link>https://soban.pl/mysql-troubleshooting-errorcode-1114/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Wed, 17 Apr 2024 13:44:22 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=454</guid>

					<description><![CDATA[<p>Introduction Working with MySQL, you may encounter various errors that can disrupt system operations. Error code 1114 is one of them and indicates a situation where the table the user is trying to write data to is full. This issue is particularly significant in the MySQL replication system, where its resolution is crucial for ensuring [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/mysql-troubleshooting-errorcode-1114/">MySQL Troubleshooting – ErrorCode: 1114</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img decoding="async" width="834" height="841" src="https://soban.pl/wp-content/uploads/2024/04/mysql_error_1114.png" alt="" class="wp-image-457" style="width:419px;height:auto" srcset="https://soban.pl/wp-content/uploads/2024/04/mysql_error_1114.png 834w, https://soban.pl/wp-content/uploads/2024/04/mysql_error_1114-298x300.png 298w, https://soban.pl/wp-content/uploads/2024/04/mysql_error_1114-150x150.png 150w, https://soban.pl/wp-content/uploads/2024/04/mysql_error_1114-768x774.png 768w" sizes="(max-width: 834px) 100vw, 834px" /></figure>



<h4 class="wp-block-heading"><br>Introduction</h4>



<p>Working with MySQL, you may encounter various errors that can disrupt system operations. Error code 1114 is one of them and indicates a situation where the table the user is trying to write data to is full. This issue is particularly significant in the MySQL replication system, where its resolution is crucial for ensuring work continuity.</p>



<h4 class="wp-block-heading">Problem Description</h4>



<p>Error 1114 manifests itself with the message: &#8220;Could not execute Write_rows event on table docs; The table &#8216;docs&#8217; is full&#8221;. This means that new rows cannot be written due to exceeding the size of the temporary table. The detailed error message might look like this:</p>



<p><strong>Login to MySQL</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># mysql -u root -p</pre></div>



<p><strong>Change variable values</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">SET GLOBAL tmp_table_size = 268435456;  -- Set to 256M
SET GLOBAL max_heap_table_size = 268435456;  -- Set to 256M</pre></div>



<p>After making these changes, all new connections to the MySQL server will use these updated values. You can verify them by performing:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">SHOW GLOBAL VARIABLES LIKE 'tmp_table_size';
SHOW GLOBAL VARIABLES LIKE 'max_heap_table_size';</pre></div>



<p>Or<br></p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">SELECT @@tmp_table_size, @@max_heap_table_size;</pre></div>



<p>Now replication can be resumed and should work better. However, remember to modify the configuration so that after restarting MySQL these variables are set correctly. It may be necessary here to resume replication (if it was previously stopped):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">START SLAVE;</pre></div>



<p>If the problem has been resolved, at this stage checking the replication status:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">show slave status \G</pre></div>



<p>Should not return any errors.<br><br><strong>Modify the configuration file <code>/etc/mysql/my.cnf</code></strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cat /etc/mysql/my.cnf
...
tmp_table_size=256M
max_heap_table_size=256M
...</pre></div>



<p><strong>Restart MySQL service</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># systemctl restart mysql</pre></div>



<p>Before restarting the service, it is recommended to execute <code>SHUTDOWN;</code> in the MySQL client.<br>Remember to resume replication.<br></p>



<h4 class="wp-block-heading">Important Notes</h4>



<ul class="wp-block-list">
<li><strong>System Resources</strong>: Ensure the server has sufficient RAM to handle the increased variable values.</li>



<li><strong>Performance Monitoring</strong>: After making the changes, monitor performance to verify that the problem has been resolved.</li>



<li><strong>Configuration Durability</strong>: Changes to the configuration file should be permanent to avoid resetting values after a restart.</li>
</ul>



<h4 class="wp-block-heading">Additional Verification Steps</h4>



<ul class="wp-block-list">
<li><strong>Check Available Disk Space</strong>: The problem might also stem from lack of available disk space. This can be verified using the following command:</li>
</ul>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># df -h</pre></div>



<h4 class="wp-block-heading">Summary</h4>



<p>Resolving the issue associated with error code 1114 in MySQL replication requires understanding and adjusting the system configuration. The described steps show how increasing the size of the temporary table can prevent this error, enabling smooth operation of the replication system.</p>
<p>Artykuł <a href="https://soban.pl/mysql-troubleshooting-errorcode-1114/">MySQL Troubleshooting – ErrorCode: 1114</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
