Add the fa-IR persian language folder picked from a 3.x site in the installation/language/ folder of 4.0
Install joomla choosing Persian as language. When getting to the db prefix, modify the default one proposed.
Error "Could not connect to database" (repeated)
Patch here #23208
Closing