October: Database connection lost after running command php artisan october:env if mysql password has quotes in database.php file

Created on 12 Mar 2020  路  6Comments  路  Source: octobercms/october

  • OctoberCMS Build: 464
  • PHP Version: 7.2.24
  • Database Engine: mysql (InnoDB)
  • Plugins Installed: october.demo-v1.0.1

Description:

Hello,

I get a mysql connection error after running command php artisan october:env ; everything worked fine before. I realized it was because I used a quote caracter (" or ') in the password. Password was correctly written in file config/database.php but quote caracter was removed in .env after running command artisan october:env.

The password was generated by ISP and I can't change it. Of course, I just could change the password in the new generated .env file ; but there is a risk that some people spend a lot of time looking for the solution.

I installed OctoberCMS via command line and composer. Password for mysql database was entered during normal CLI installation.

Steps To Reproduce:

  1. Install OctoberCMS via composer command composer create-project october/october myoctober
  2. Enter a password for mysql database during normal database questions. Enter for example 3$Zvt?2dF.~"fZ*
  3. Finalize installation and check that everything works fine (frontend and backend)
  4. Execute command php artisan october:env for creating dot env configuration file
  5. Refresh backend end and confirm that there is now a mysql error (missing database)
  6. Open the new created .env file and check that quote caracter is missing for mysql password : 3$Zvt?2dF.~fZ*

Issue is something similar to #3054 and #2361.

Something else ?

Yes ! Thanks a lot for your work and this amazing CMS !

Completed Bug

Most helpful comment

@bennothommo we also need to make sure that the october:env command is surrounding all env values with quotes, or at the very least any with a # character in it.

All 6 comments

I've confirmed that this is in fact a bug and created a pull request that addresses this issue:

https://github.com/octobercms/october/pull/4983

Hope it gets accepted :)

@bennothommo we also need to make sure that the october:env command is surrounding all env values with quotes, or at the very least any with a # character in it.

@LukeTowers I'll have to run some tests, because I believe a quote in the middle of a string is invalid as well if it's not escaped - I presume this is why it was opted to just remove them completely.

I've confirmed that this is in fact a bug and created a pull request that addresses this issue:

4983

Hope it gets accepted :)

Thanks a lot !

@najbo I'm going to re-open this as it is a confirmed bug and I'm working on a unit test and possible fix (if @bugzbrown is unable to complete their fix).

Okay perfect, thanks a lot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

m49n picture m49n  路  3Comments

sozonovalexey picture sozonovalexey  路  3Comments

gergo85 picture gergo85  路  3Comments

d3monfiend picture d3monfiend  路  3Comments

axomat picture axomat  路  3Comments