DB error when running grunt exec Magento2
Question
I am running grunt exec:luma
and am getting the following errors:
Processed Area: frontend, Locale: en_GB, Theme: Magento/luma, File type: less.
>> [Zend_Db_Adapter_Exception]
>> SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
>>
>>
>> [PDOException]
>> SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
>>
>>
>>
>> dev:source-theme:deploy [--type="..."] [--locale="..."] [--area="..."] [--theme="..."] [file1] ... [fileN]
>> Exited with code: 255.
Warning: Task "exec:luma" failed. Use --force to continue.
Aborted due to warnings.
Steps I have taken are as follows:
Clean theme by command:
grunt clean
run command:
grunt exec:yourthemename
I don't have a clue why I am getting a DB error can anyone shed any light into this. DB credentials I'm just confused as to why the Grunt task would be even interacting with the DB.
My Magento 2 set up is running on an Nginx server
Solution
grunt exec is esentially a shorthand for clearing the folders var/view_preprocessed, var/generation, var/log/system.log and pub/static
and running
php bin/magento dev:source-theme:deploy --type=less --locale=en_US --area=frontend --theme=Package/theme
So before running grunt commands you need to make sure that your comand line php is the same as the server php and that it has access to the database. You get that error because your comand line php does not have access to the database. Also make sure that the user with which you are running grunt has access to delete the var and pub/static volders.
OTHER TIPS
Probably you run the grunt task from your local machine. In Magento 2 grunt is supposed to run server side.