<?xml version="1.0"?>
<rss version="2.0"><channel><title>MariaDB/MySQL Latest Topics</title><link>https://www.alphagnu.com/forum/15-mariadbmysql/</link><description>MariaDB/MySQL Latest Topics</description><language>en</language><item><title>Optimize Mariadb/MySQL server for 4 GB RAM Server</title><link>https://www.alphagnu.com/topic/16-optimize-mariadbmysql-server-for-4-gb-ram-server/</link><description><![CDATA[<p>
	If you have a MariaDB/MySQL VPS server with 4GB of RAM, you can optimize its performance by following these steps:
</p>

<p>
	If you’re looking for more than 4gb of ram configuration just divide the value with 4 and multiply the result with the amount of RAM, for example : 256/4 = 64 and you want it for 8 gb of ram just multiply it with the result i.e. 64 x 8 = 512
</p>

<p>
	<strong>For MariaDB :</strong><br />
	Edit the MariaDB configuration file /etc/my.cnf.d/server.cnf using your favorite text editor:
</p>

<p>
	nano /etc/my.cnf.d/server.cnf<br />
	Add the following lines under the [mysqld] section:
</p>

<pre class="ipsCode">default-storage-engine = InnoDB
innodb_flush_method = O_DIRECT
innodb_log_file_size = 128M
innodb_buffer_pool_size = 128M
max_allowed_packet = 128M
max_connections = 200
key_buffer_size = 256M
tmp_table_size = 64M
max_heap_table_size = 64M</pre>

<p>
	<br />
	<strong>For MySQL :</strong><br />
	Edit the MySQL configuration file /etc/my.cnf using your favorite text editor:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">nano /etc/my.cnf</span></pre>

<p>
	<br />
	Add the following lines under the [mysqld] section:
</p>

<pre class="ipsCode">default-storage-engine = InnoDB
innodb_flush_method = O_DIRECT
innodb_log_file_size = 128M
innodb_buffer_pool_size = 128M
max_allowed_packet = 128M
max_connections = 200
key_buffer_size = 256M
tmp_table_size = 64M
max_heap_table_size = 64M</pre>

<p>
	<br />
	After you’ve added this values restart MariaDB/Mysql server :
</p>

<p>
	MariaDB server restart :
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">systemctl restart mariadb</span></pre>

<p>
	<br />
	MySQL server restart :
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">systemctl restart mysql mysqld</span></pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">16</guid><pubDate>Fri, 02 Jun 2023 14:12:38 +0000</pubDate></item><item><title>Import Big file Size of Database to MySQL</title><link>https://www.alphagnu.com/topic/353-import-big-file-size-of-database-to-mysql/</link><description><![CDATA[<p>
	HI, I would to Import and big database file around 2.5 G, to a user account(website) kindly guide on how can I cope with please.
</p>

<p>
	Note: I used this command : mysql -u alemaren_gild -p alemaren_statute &lt; alemaren_english.sql but it's not working and I getting access dined error.
</p>

<p>
	waiting for you help
</p>

<p>
	thanks.
</p>
]]></description><guid isPermaLink="false">353</guid><pubDate>Sun, 10 Mar 2024 03:55:39 +0000</pubDate></item><item><title>504 gateway time-out phpmyadmin</title><link>https://www.alphagnu.com/topic/284-504-gateway-time-out-phpmyadmin/</link><description><![CDATA[<p>
	Dear sandep
</p>

<p>
	I have a problem uploading a file through phpmyadmin
</p>

<p>
	the sql file size 10mb zip
</p>

<p>
	shows the following error "504 gateway time-out"
</p>

<p>
	I would like to know if you can help me.
</p>

<p>
	thank you
</p>
]]></description><guid isPermaLink="false">284</guid><pubDate>Wed, 28 Feb 2024 18:35:24 +0000</pubDate></item><item><title>How to Reset root password in MariaDB 11.xx/10.xx and Mysql 8.0</title><link>https://www.alphagnu.com/topic/76-how-to-reset-root-password-in-mariadb-11xx10xx-and-mysql-80/</link><description><![CDATA[<p>
	In this tutorial I’ll provide you the steps to reset root password for MySQL 8.0 and MariaDB 10.4/10.xx/11.xx easily and efficiently. Since this are latest version of MySQL and fork mariadb you should do some extra caution during root password reset. Below are the easy steps to reset the root password.
</p>

<p>
	If you’re getting below error then it seems root password is not working or something bad happens to MySQL root user :
</p>

<p>
	<strong>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)</strong>
</p>

<p>
	Lets get started with MySQL/mariadb root password reset :-
</p>

<p>
	<strong>First stop the MySQL/Mariadb service :</strong>
</p>

<pre class="ipsCode">systemctl stop mysqld mariadb mysql
service mysqld stop / service mariadb stop</pre>

<p>
	<br />
	<strong>Then you need to run the below command to start mysql with skip-grant-tables option :</strong>
</p>

<pre class="ipsCode">mysqld --skip-grant-tables --user=root &amp;</pre>

<p>
	<br />
	if upper user with root not work you can use below with mysql
</p>

<pre class="ipsCode">mysqld --skip-grant-tables --user=mysql &amp;</pre>

<p>
	<br />
	After running the above command press “Enter” Key or "ctrl+c" &gt; to get the shell again
</p>

<p>
	<strong>Then you need to run mysql command and then run flush privileges command under MySQL CLI:</strong>
</p>

<pre class="ipsCode">mysql
FLUSH PRIVILEGES;</pre>

<p>
	<br />
	<strong>Then at last change the MySQL/Mariadb root password :</strong>
</p>

<pre class="ipsCode">ALTER USER 'root'@'localhost' IDENTIFIED BY 'root_passowrd';</pre>

<p>
	<br />
	Replace “root_password” with some password.
</p>

<p>
	then exit from MySQL cli by typing “<strong>quit</strong>“
</p>

<p>
	<strong>Then run this command to kill all mysql processes :</strong>
</p>

<pre class="ipsCode">killall -u mysql

or

pkill -U mysql</pre>

<p>
	<br />
	<strong>Ensure by running this command to unset environments if you accidentally set any :</strong>
</p>

<pre class="ipsCode">systemctl unset-environment MYSQLD_OPTS</pre>

<p>
	<br />
	Now Stop and restart mysql
</p>

<pre class="ipsCode">systemctl stop mysql mysqld mariadb &amp;&amp; systemctl start mysql mysqld mariadb
service mysqld stop &amp;&amp; service mysqld restart</pre>

<p>
	some time mysql/mariadb process are still running you need to kill them manually you can find the process via top command : <strong>top -u mysql</strong>
</p>

<p>
	if it is running then you need to kill the pid with<strong> kill -9 "pid no." </strong>and restart mysql/mariadb
</p>

<p>
	Thats it you’re done with root password reset for MySQL
</p>

<p>
	Check by logging into mysql root.
</p>

<p>
	<strong>CWP and for other control panels only :</strong>
</p>

<p>
	On control panel like cwp and other panel having /root/.my.cnf ensure you’ve updated the file with new root password which you changed it via upper command
</p>

<p>
	<strong>For CWP only update the new password in this files:</strong>
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			/root/.my.cnf<br />
			/usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php
		</p>
	</div>
</blockquote>

<p>
	 
</p>
]]></description><guid isPermaLink="false">76</guid><pubDate>Thu, 10 Aug 2023 04:47:45 +0000</pubDate></item><item><title>Optimize and Repair MySQL Database via CLI - command line</title><link>https://www.alphagnu.com/topic/32-optimize-and-repair-mysql-database-via-cli-command-line/</link><description><![CDATA[<p>
	Today we’ll learn how we can optimize and repair MySQL databases via command line interface, probably you’ve already optimized and repaired dbs via phpMyAdmin options and its easy to use, but what about you’ve too many databases and wanting to repair and optimize it at once?
</p>

<p>
	No worry today I’ll show you easy way to do it via CLI with single command each for repairing and optimizing databases.
</p>

<p>
	<strong>To Repair ALL Database you need to simply run this command :</strong>
</p>

<pre class="ipsCode">mysqlcheck -r --all-databases</pre>

<p>
	<br />
	If you want to Repair single database then use this :
</p>

<pre class="ipsCode">mysqlcheck -r user_db</pre>

<p>
	<br />
	*user_db is the db name, replace with your one.
</p>

<p>
	<strong>To Optimize ALL Database you need to simply run this command :</strong>
</p>

<pre class="ipsCode">mysqlcheck -o --all-databases</pre>

<p>
	<br />
	If you want to Optimize single database then use this :
</p>

<pre class="ipsCode">mysqlcheck -o user_db</pre>

<p>
	<br />
	*user_db is the db name, replace with your one.
</p>

<p>
	<strong>Extras :</strong><br />
	If you need to specify username to do the repair and optimize task you can add this pipes :
</p>

<pre class="ipsCode">mysqlcheck -r  -u root -p --all-databases
mysqlcheck -o  -u root -p --all-databases</pre>

<p>
	<br />
	of for single database :
</p>

<pre class="ipsCode">mysqlcheck -r user_db -u root -p
mysqlcheck -o user_db -u root -p</pre>

<p>
	<br />
	*this will ask the password for mysql root user
</p>
]]></description><guid isPermaLink="false">32</guid><pubDate>Sat, 03 Jun 2023 17:29:54 +0000</pubDate></item><item><title>How to Disable MySQL Strict Mode in MariaDB and MySQL</title><link>https://www.alphagnu.com/topic/26-how-to-disable-mysql-strict-mode-in-mariadb-and-mysql/</link><description><![CDATA[<p>
	learn how you can easily disable mysql strict mode in MySQL/MariaDB Server on any Linux os such as Centos/Ubuntu/RHEL/AlmaLinux and in Linux Server Control panel like CWP, HestiaCP etc.
</p>

<p>
	Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. 
</p>

<p>
	To Disable MySQL strict mode simply add below config in my.cnf usually in /etc/my.cnf ensure you added it under [mysqld] section see example below in this tutorial :
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">sql_mode="NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"</span></pre>

<p>
	<br />
	How to find the my.cnf ? mostly my.cnf is located in this locations :
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			/etc/my.cnf <br />
			/etc/mysql/my.cnf 
		</p>
	</div>
</blockquote>

<p>
	<br />
	if there is no my.cnf files then create one in this location /etc/my.cnf with below config :
</p>

<pre class="ipsCode">#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]

[mysqld]
sql_mode="NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

#
# include *.cnf from the config directory
#
!includedir /etc/my.cnf.d</pre>

<p>
	<br />
	**please note you need to change the permission if you’ve newly created the my.cnf to <strong>user:group</strong> i.e. :<strong> mysql:mysql</strong>
</p>
]]></description><guid isPermaLink="false">26</guid><pubDate>Sat, 03 Jun 2023 17:02:45 +0000</pubDate></item><item><title>Enable Query Cache in MariaDB for Performance CWP hestiacp Centos Ubuntu</title><link>https://www.alphagnu.com/topic/15-enable-query-cache-in-mariadb-for-performance-cwp-hestiacp-centos-ubuntu/</link><description><![CDATA[<p>
	Today we’ll learn how you can enable query cache in MariaDB server, it has several caching mechanisms to improve performance the query cache stores results of SELECT queries so that if the identical query is received in future, the results can be quickly returned.
</p>

<p>
	This is extremely useful in high-read, low-write environments (such as most websites). It does not scale well in environments with high throughput on multi-core machines, so it is disabled by default.
</p>

<p>
	<strong>Here are the steps to enable query cache in MariaDB:</strong>
</p>

<p>
	Check if query cache is enabled:
</p>

<p>
	Before enabling query cache, you should check if it’s already enabled or not. You can do this by logging into your MariaDB server and executing the following command:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">SHOW VARIABLES LIKE 'query_cache_type';</span></pre>

<p>
	<br />
	example :
</p>

<p>
	type mysql in command line and hit enter it will bring the mysql console and then execute show variable command
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">[root@server ]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.11.2-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]&gt; SHOW VARIABLES LIKE 'query_cache_type';

+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| query_cache_type | OFF   |
+------------------+-------+

1 row in set (0.001 sec)</span></pre>

<p>
	<br />
	If the value of query_cache_type is OFF, it means that query cache is not enabled.
</p>

<p>
	<strong>Enable query cache:</strong>
</p>

<p>
	To enable query cache, you need to modify the mariadb configuration file and add the below configs under [mysqld] section.
</p>

<p>
	For CWP/centos file is located in : /etc/my.cnf or /etc/my.cnf.d/server.cnf
</p>

<p>
	For ubuntu/Debian file is located in : /etc/mysql/my.cnf
</p>

<p>
	Open the file in a text editor and add the following lines:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">query_cache_type = 1
query_cache_size = 128M
query_cache_limit = 4M</span></pre>

<p>
	<br />
	The query_cache_type variable is set to 1 to enable query cache, query_cache_size specifies the size of the cache in megabytes, and query_cache_limit specifies the maximum size of a single query that can be cached.
</p>

<p>
	Restart MariaDB server:
</p>

<p>
	After modifying the my.cnf configuration file, you need to restart the MariaDB server to apply the changes. You can do this by running the following command:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">systemctl restart mariadb</span></pre>

<p>
	<br />
	Verify query cache is enabled:
</p>

<p>
	To verify that query cache is enabled, you can log into the MariaDB server and execute the <strong>SHOW VARIABLES LIKE 'query_cache_type';</strong> command again. If the value of <strong>query_cache_type is now ON</strong>, it means that query cache has been enabled.
</p>

<p>
	By following these steps, you can enable query cache in MariaDB and improve the performance of your database queries.
</p>
]]></description><guid isPermaLink="false">15</guid><pubDate>Fri, 02 Jun 2023 14:10:31 +0000</pubDate></item></channel></rss>
