Joomla and MySQL 8: Difference between revisions

From Joomla! Documentation

Cmb (talk | contribs)
Several markup and capitalization changes.
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
=== MySQL default authentication plugin issue  ===
<noinclude><languages /></noinclude>
It's not possible to connect to a MySQL 8 Database using Joomla 3.8, 3.9 or 4.0. The reason is that MySQL 8 has a lot of changes under the hood. One change that affects Joomla is the default authentication plugin which is <code>sha256_password </code>instead of <code> mysql_native_password</code>. The native PHP MySQL-Driver don't support MySQL 8 with this plugin yet other programming languages like GO or PERL are struggling too. [https://github.com/php/php-src/commit/d6e81f0bfd0cb90586dd83d4fd47a4302605261a PHP 7.3 (alpha)] is supporting MySQL 8 though.  
<translate>
=== Workaround to get Joomla working with MySQL 8 ===
==MySQL Default Authentication Plugin Issue== <!--T:1-->
Fortunately there is a workaround! We just have to use the <code>mysql_native_password</code> default authentication plugin for MySQL.
</translate>
We just need to open our configuration file <code>sudo nano /etc/my.cnf</code> (please note that your file may be under a different directory)) and add following configuration:  
<translate><!--T:2--> It is possible to connect to a MySQL 8 Database using Joomla {{JVer|3.x}}, however it requires a customisation on the MySQL 8 installation configuration. The reason is that MySQL 8 has many low-level changes including the default authentication plugin changing to ''sha256_password'' from ''mysql_native_password''. The native PHP MySQL-Driver doesn't currently support MySQL 8 with this plugin. [https://github.com/php/php-src/commit/d6e81f0bfd0cb90586dd83d4fd47a4302605261a PHP 7.3 (alpha)] is supporting MySQL 8 though.</translate>
<br>
 
<source>
<translate>
==MySQL Configuration Change to Get Joomla Working with MySQL 8== <!--T:3-->
</translate>
<translate><!--T:4-->
If you edit the configuration file for MySQL 8, you can change the default authentication plugin for MySQL to use the older ''mysql_native_password''.
Open your configuration file ''sudo nano /etc/my.cnf''. (Note that your file may be under a different directory.) Add this configuration:</translate>
<syntaxhighlight lang="ini">
[mysqld]
[mysqld]
default-authentication-plugin=mysql_native_password
default-authentication-plugin=mysql_native_password
</source>  
</syntaxhighlight>
If you don't have access to your config file then you can just update your user with:
<translate><!--T:5--> If you don't have access to your config file, you can update your user:</translate>
<br>
<syntaxhighlight lang="mysql">
<source>
ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
</syntaxhighlight>
</source>  
<translate><!--T:6--> Replace ''username'' with the name of the user account and ''password'' with the password belonging to the account. Restart MySQL and you are done. Well, only if you have Joomla 3.8 or 3.9 installed.</translate>
Restart the server and your done, well only if you have Joomla 3.8 or 3.9 installed.
 
<br>
<translate>
<br>
==How MySQL Default Authentication Plugin Works== <!--T:11-->
<br>
</translate>
If you want to work with Joomla 4.0 you have to do some extra work, because the administration dashboard is blank after the installation with Joomla 4.0 and MySQL 8.
<translate><!--T:12--> The advantage of ''mysql_native_password'' is that it supports the challenge/response mechanism which is quick and does not require encrypted connection. However, ''mysql_native_password'' relies on SHA1 algorithm and NIST has recommended to stop using it.</translate>
<br>
Fortunately there is a fix for that too!  
MySQL 8 is returning <code>Incorrect date value: '0000-00-00'</code> after running following insertion from that path<code>/Applications/MAMP/htdocs/joomla-cms/installation/sql/mysql/joomla.sql</code>:
<source lang=sql>
INSERT INTO `#__modules` (`id`, `asset_id`, `title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES
(1, 39, 'Main Menu', '', '', 1, 'sidebar-right', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_menu', 1, 1, '{"menutype":"mainmenu","startLevel":"0","endLevel":"0","showAllChildren":"1","tag_id":"","class_sfx":"","window_open":"","layout":"","moduleclass_sfx":"_menu","cache":"1","cache_time":"900","cachemode":"itemid"}', 0, '*');
</source>
This is happening because since MYSQL 5.7, MYSQL stops supporting zeros value in date / datetime.
If you change the value to <code>CURRENT_TIMESTAMP</code>, <code>NULL</code> or <code>'1970-01-01'</code> everything should work fine.


=== How MySQL default authentication plugin works ===
<translate><!--T:13--> Further, if two user accounts use the same password, ''mysql_native_password'' transformation is the same in the ''mysql.user'' table. Although the hash does not expose information about the actual password, it still tells which two users use the same password. To avoid that, a salt should be used. A salt is a random number that is used as one of the parameters to cryptographic hash functions used to transform user passwords. Since a salt is random and different for each execution, even if two users use the same passwords, the end result of transformation would look different.</translate>
The advantage of mysql_native_password is that it support challenge-response mechanism which is very quick and does not require encrypted connection. However, mysql_native_password relies on SHA1 algorithm and NIST has suggested to stop using it.


Further, if two user accounts use the same password, mysql_native_password transformation is the same in the mysql.user table. Although the hash does not expose information about the actual password, it still tells which two users use the same password. To avoid that, salt should be used. Salt is basically a random number that is used as one of the inputs to cryptographic hash functions used to transform user passwords. Since salt is random and different for each execution, even if two users use the same passwords, the end result of transformation would look very different.
<translate>
<!--T:14-->
Since MySQL 5.6, the ''sha256_password'' authentication plugin is supported. It uses multiple rounds of SHA256 hash on a salted password to make sure that the hash transformation is more secure. However, it requires either encrypted connections or support for an RSA key pair. So, while password security is stronger, secure connections and multiple rounds of hash transformations require more time in the authentication process.</translate>


Since MySQL 5.6, sha256_password authentication plugin is supported. It uses multiple rounds of SHA256 hash on a salted password to make sure that the hash transformation is more secure. However, it requires either encrypted connections or support for an RSA key pair. So, while password security is stronger, secure connections and multiple rounds of hash transformations require more time in the authentication process.
<translate><!--T:15--> The ''caching_sha2_password'' tries to combine the best of both worlds.</translate> <ref>https://mysqlserverteam.com/mysql-8-0-4-new-default-authentication-plugin-caching_sha2_password/</ref>


caching_sha2_password tries to combine the best of both worlds. <ref> https://mysqlserverteam.com/mysql-8-0-4-new-default-authentication-plugin-caching_sha2_password/ </ref>
<noinclude>
[[Category:Server configurations{{#translation:}}]]
[[Category:Installation{{#translation:}}]]
[[Category:Tutorials{{#translation:}}]]
</noinclude>

Latest revision as of 22:42, 27 November 2022

MySQL Default Authentication Plugin Issue

It is possible to connect to a MySQL 8 Database using Joomla Joomla 3.x, however it requires a customisation on the MySQL 8 installation configuration. The reason is that MySQL 8 has many low-level changes including the default authentication plugin changing to sha256_password from mysql_native_password. The native PHP MySQL-Driver doesn't currently support MySQL 8 with this plugin. PHP 7.3 (alpha) is supporting MySQL 8 though.

MySQL Configuration Change to Get Joomla Working with MySQL 8

If you edit the configuration file for MySQL 8, you can change the default authentication plugin for MySQL to use the older mysql_native_password. Open your configuration file sudo nano /etc/my.cnf. (Note that your file may be under a different directory.) Add this configuration:

[mysqld]
default-authentication-plugin=mysql_native_password

If you don't have access to your config file, you can update your user:

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Replace username with the name of the user account and password with the password belonging to the account. Restart MySQL and you are done. Well, only if you have Joomla 3.8 or 3.9 installed.

How MySQL Default Authentication Plugin Works

The advantage of mysql_native_password is that it supports the challenge/response mechanism which is quick and does not require encrypted connection. However, mysql_native_password relies on SHA1 algorithm and NIST has recommended to stop using it.

Further, if two user accounts use the same password, mysql_native_password transformation is the same in the mysql.user table. Although the hash does not expose information about the actual password, it still tells which two users use the same password. To avoid that, a salt should be used. A salt is a random number that is used as one of the parameters to cryptographic hash functions used to transform user passwords. Since a salt is random and different for each execution, even if two users use the same passwords, the end result of transformation would look different.

Since MySQL 5.6, the sha256_password authentication plugin is supported. It uses multiple rounds of SHA256 hash on a salted password to make sure that the hash transformation is more secure. However, it requires either encrypted connections or support for an RSA key pair. So, while password security is stronger, secure connections and multiple rounds of hash transformations require more time in the authentication process.

The caching_sha2_password tries to combine the best of both worlds. [1]