Log in to the Magento server as, or switch to, a user with permissions to write to the Magento file system. See switch to the file system owner.
If you use the bash shell, you can use the following syntax to switch to the file system owner and enter the command at the same time:
su <file system owner> -s /bin/bash -c <command>
If the file system owner does not allow logins, you can do the following:
sudo -u <file system owner> <command>
To run Magento commands from any directory, add
<magento_root>/binto your system
Because shells have differing syntax, consult a reference like unix.stackexchange.com.
Sample bash shell for CentOS:
Optionally, you can run the commands in the following ways:
cd <magento_root>/binand run them as
./magento <command name>
<magento_root>/bin/magento <command name>
<magento_root>is a subdirectory of your web server docroot.
In addition to the command arguments discussed here, see Common arguments.
Before you use this command, you must install the Magento software.
Upgrade the Magento database schema and data
Anytime you perform an action that causes the Magento database schema or data to change, you must update them by running the command discussed in this section. A partial list of reasons follows:
- You upgraded the Magento software using the command line
- You installed or updated a component using the command line
- You enabled or disabled a component using the command line
A Magento component can be a module, theme, or language pack; it doesn’t matter whether the component comes from the Commerce Marketplace or not
Start the upgrade:
bin/magento setup:upgrade [--keep-generated]
--keep-generatedis an optional argument that does not update static view files. This optional argument is for use only in limited circumstances by experienced system integrators. It should be used only in production mode. It should not be used in developer mode.
Clean the cache: