How to change WordPress user roles in MySQL database using PhpMyAdmin?

Usually you change a user’s role under Users in the WordPress admin. Sometimes that isn’t possible: you’re locked out after a hack, a plugin has removed your administrator role, or you only have access to the database through your hosting panel. In those cases you can set the role directly in the database. We will be editing the database rows using the phpMyAdmin tool that many hosting companies provide with cPanel. Before you change anything, export the database (or at least the wp_usermeta table) from phpMyAdmin so you can restore it if something goes wrong. ...

August 2, 2018 · 3 min · Harshvardhan Malpani

Magento 2 cli commands [continued]

More Magento 2 settings that I change from the command line instead of the admin. All three live under Stores > Configuration > Advanced > Developer. From Magento 2.2, that Developer section isn’t shown in the admin while the store runs in production mode, so on a live store the command line (or the database) is the practical way to change them. Each setting has two versions of the command. Magento 2.2 added bin/magento config:set, which changes any configuration value by its path. On older versions you update the core_config_data table directly with the mysql client. ...

August 1, 2018 · 4 min · Harshvardhan Malpani

How to install theme in Magento 2

Most Magento 2 themes bought from a marketplace come as a zip file with an app folder inside. The theme itself lives in app/design/frontend/<Vendor>/<theme>, and some themes also bring their own modules in app/code. Installing it means copying those files into Magento, letting Magento register them, building the static files, and then switching the store over to the new theme. These steps were written for Magento 2.2 in 2018. Before you start ...

July 29, 2018 · 3 min · Harshvardhan Malpani

[SOLVED] PHP must be run as a CLI application error : Content-type: text/html; charset=UTF-8

On cPanel servers, running Magento’s bin/magento over SSH can fail straight away with output like this: php bin/magento cache:clean Content-type: text/html; charset=UTF-8 bin/magento must be run as a CLI application The Content-type line is an HTTP header. It means the php command you ran is the CGI build of PHP, the one meant to run behind a web server, rather than the command-line (CLI) build. Magento checks which one it’s running under and refuses to work unless it’s the CLI. ...

July 28, 2018 · 2 min · Harshvardhan Malpani

MySQL error 1449: The user specified as a definer does not exist

Why this error happens? Most of the times, reason is that your database dump through command line or PhpMyAdmin or even other libraries can have SQL’s Definer statements. Now, as per MySQL’s Official Documentation: The DEFINER clause specifies the MySQL account to be used when checking access privileges at routine execution time for routines that have the SQL SECURITY DEFINER characteristic. MySQL Reference Manual v8.0 In practice, every view, trigger, stored procedure, function and event remembers the MySQL account that created it: its definer, written as 'user'@'host'. A dump keeps those definers. When you import it on another server where that account doesn’t exist, for example a dump of the live database loaded onto your local machine, the objects still point at the missing account, and using them fails with error 1449, “The user specified as a definer (‘user’@‘host’) does not exist”. ...

July 28, 2018 · 3 min · Harshvardhan Malpani

Magento 2 all cli commands

This is the complete output of php bin/magento list on a Magento 2.2.4 store. I keep it here as a quick reference for everything the Magento command-line tool can do, without having to log in to a server to look it up. The list depends on the Magento version and the extensions installed, so run the same command in your own Magento root to see exactly what’s available there. [~/www]# php bin/magento list Magento CLI version 2.2.4 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: help Displays help for a command list Lists commands admin admin:user:create Creates an administrator admin:user:unlock Unlock Admin Account app app:config:dump Create dump of application app:config:import Import data from shared configuration files to appropriate data storage cache cache:clean Cleans cache type(s) cache:disable Disables cache type(s) cache:enable Enables cache type(s) cache:flush Flushes cache storage used by cache type(s) cache:status Checks cache status catalog catalog:images:resize Creates resized product images catalog:product:attributes:cleanup Removes unused product attributes. config config:sensitive:set Set sensitive configuration values config:set Change system configuration config:show Shows configuration value for given path. If path is not specified, all saved values will be shown cron cron:install Generates and installs crontab for current user cron:remove Removes tasks from crontab cron:run Runs jobs by schedule customer customer:hash:upgrade Upgrade customer's hash according to the latest algorithm deploy deploy:mode:set Set application mode. deploy:mode:show Displays current application mode. dev dev:di:info Provides information on Dependency Injection configuration for the Command. dev:profiler:disable Disable the profiler. dev:profiler:enable Enable the profiler. dev:query-log:disable Disable DB query logging dev:query-log:enable Enable DB query logging dev:source-theme:deploy Collects and publishes source files for theme. dev:template-hints:disable Disable frontend template hints. A cache flush might be required. dev:template-hints:enable Enable frontend template hints. A cache flush might be required. dev:tests:run Runs tests dev:urn-catalog:generate Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml. dev:xml:convert Converts XML file using XSL style sheets i18n i18n:collect-phrases Discovers phrases in the codebase i18n:pack Saves language package i18n:uninstall Uninstalls language packages import import:categories Run category importer script indexer indexer:info Shows allowed Indexers indexer:reindex Reindexes Data indexer:reset Resets indexer status to invalid indexer:set-mode Sets index mode type indexer:show-mode Shows Index Mode indexer:status Shows status of Indexer info info:adminuri Displays the Magento Admin URI info:backups:list Prints list of available backup files info:currency:list Displays the list of available currencies info:dependencies:show-framework Shows number of dependencies on Magento framework info:dependencies:show-modules Shows number of dependencies between modules info:dependencies:show-modules-circular Shows number of circular dependencies between modules info:language:list Displays the list of available language locales info:timezone:list Displays the list of available timezones maintenance maintenance:allow-ips Sets maintenance mode exempt IPs maintenance:disable Disables maintenance mode maintenance:enable Enables maintenance mode maintenance:status Displays maintenance mode status module module:disable Disables specified modules module:enable Enables specified modules module:status Displays status of modules module:uninstall Uninstalls modules installed by composer sampledata sampledata:deploy Deploy sample data modules sampledata:remove Remove all sample data packages from composer.json setup setup:backup Takes backup of Magento Application code base, media and database setup:config:set Creates or modifies the deployment configuration setup:cron:run Runs cron job scheduled for setup application setup:db-data:upgrade Installs and upgrades data in the DB setup:db-schema:upgrade Installs and upgrades the DB schema setup:db:status Checks if DB schema or data requires upgrade setup:di:compile Generates DI configuration and all missing classes that can be auto-generated setup:install Installs the Magento application setup:performance:generate-fixtures Generates fixtures setup:rollback Rolls back Magento Application codebase, media and database setup:static-content:deploy Deploys static view files setup:store-config:set Installs the store configuration. Deprecated since 2.2.0. Use config:set instead setup:uninstall Uninstalls the Magento application setup:upgrade Upgrades the Magento application, DB data, and schema store store:list Displays the list of stores store:website:list Displays the list of websites theme theme:uninstall Uninstalls theme varnish varnish:vcl:generate Generates Varnish VCL and echos it to the command line How to read the list The first line is the shell prompt and the command, run from the Magento root (~/www on that server). The second line shows the version of the CLI. Usage is the general form of every command: php bin/magento <command> [options] [arguments]. Options work with any command. The most useful are -v, -vv and -vvv for more detail when a command fails, -n to skip interactive questions when a command runs from a script, and --no-ansi to drop the colour codes when saving the output to a log file. Available commands are grouped by the word before the first colon, so cache:clean and cache:flush both sit under cache. The text on the right is the command’s own description. To see the arguments and options of a single command, run php bin/magento help cache:clean, or add --help to any command. Commands can also be shortened as long as the abbreviation matches only one command: php bin/magento c:f runs cache:flush. ...

July 27, 2018 · 7 min · Harshvardhan Malpani

How to connect cpanel through SSH

Following are the steps to connect to cpanel through SSH:- Go to your cpanel and create a public private key-pair, under SSH access->manage keys. Under manage keys section, go on create a new key. Create a key and give key name, key password, key type and key size. 4. Click on generate keys and it will look something like this. Go back and under public key section , select your public key->manage->authorize key. ...

July 27, 2018 · 1 min · Harshvardhan Malpani

Magento File Directory

/app The etc folder contains the di.xml configuration file The di.xml file contains class mapping and interface preferences Contains the design folder for themes. /bin The directory contains the magento file or a Command Line Interface script /dev Magento 2 testing and development tools are placed in this folder. /lib The internal and web subfolders are located here The internal directory contains server-side libraries and several font files; The web subfolder contains client-side libraries, jquery, modernizr, requirejs, prototype, scriptaculous ...

July 27, 2018 · 1 min · Harshvardhan Malpani

Linux commands for SSH

tar– to create archive files(.zip, .tar) Syntax: tar [options] [archive-file] [file or directory to be archived] Options: -c : Creates Archive -x : Extract the archive -f : creates archive with given filename -t : displays or lists files in archived file -u : archives and adds to an existing archive file -v : Displays Verbose Information -A : Concatenates the archive files -z : zip, tells tar command that create tar file using gzip -j : filter archive tar file using tbzip -W : Verify a archive file -r : update or add file or directory in already existed .tar file ...

July 27, 2018 · 4 min · Harshvardhan Malpani

.htaccess redirect from http to https and from non-www to www redirect – Make site permanently SSL secured

After installing an SSL certificate, I want every version of the address (http:// or https://, with or without www) to end up on the single HTTPS www address with a permanent redirect. Visitors then always get the secure site, old links keep working, and search engines index only one version of each page. On Apache, these four lines in .htaccess do it. Put this in your htaccess file: RewriteCond %{HTTP_HOST} !^www\.(.*) RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] How it works The first pair adds the www: ...

July 27, 2018 · 3 min · Harshvardhan Malpani