Use the -d command line option:
-d
php -d memory_limit=-1 <your command>
php -d memory_limit=-1 bin/magento setup:upgrade
-d --define Set a custom value for any of the configuration directives allowed in php.ini.
http://php.net/manual/en/features.commandline.options.php