88
99namespace OC \Setup ;
1010
11- use Doctrine \DBAL \Platforms \MySQL80Platform ;
1211use Doctrine \DBAL \Platforms \MySQL84Platform ;
1312use OC \DatabaseSetupException ;
1413use OC \DB \ConnectionAdapter ;
@@ -30,6 +29,19 @@ public function setupDatabase(): void {
3029 $ connection = $ this ->connect (['dbname ' => null ]);
3130 }
3231
32+ // for MD5 support
33+ if ($ connection ->getDatabasePlatform () instanceof MySQL84Platform) {
34+ $ statement = $ connection ->prepare ("SHOW VARIABLES LIKE 'version'; " );
35+ $ result = $ statement ->executeQuery ();
36+ $ row = $ result ->fetchAssociative ();
37+ $ version = $ row ['Value ' ];
38+ [$ major , ] = explode ('. ' , strtolower ($ version ));
39+ if ((int )$ major >= 9 ) {
40+ $ statement = $ connection ->prepare ("INSTALL COMPONENT 'file://component_classic_hashing'; " );
41+ $ statement ->executeStatement ();
42+ }
43+ }
44+
3345 if ($ this ->tryCreateDbUser ) {
3446 $ this ->createSpecificUser ('oc_admin ' , new ConnectionAdapter ($ connection ));
3547 }
@@ -103,12 +115,6 @@ private function createDBUser(IDBConnection $connection): void {
103115 $ connection ->executeStatement ($ query , [$ name ,$ password ]);
104116 $ query = "CREATE USER ?@'%' IDENTIFIED WITH caching_sha2_password BY ? " ;
105117 $ connection ->executeStatement ($ query , [$ name ,$ password ]);
106- } elseif ($ connection ->getDatabasePlatform () instanceof Mysql80Platform) {
107- // TODO: Remove this elseif section as soon as MySQL 8.0 is out-of-support (after April 2026)
108- $ query = "CREATE USER ?@'localhost' IDENTIFIED WITH mysql_native_password BY ? " ;
109- $ connection ->executeStatement ($ query , [$ name ,$ password ]);
110- $ query = "CREATE USER ?@'%' IDENTIFIED WITH mysql_native_password BY ? " ;
111- $ connection ->executeStatement ($ query , [$ name ,$ password ]);
112118 } else {
113119 $ query = "CREATE USER ?@'localhost' IDENTIFIED BY ? " ;
114120 $ connection ->executeStatement ($ query , [$ name ,$ password ]);
0 commit comments