Set a field as UNIQUE KEY in Magento 2 Setup Schema

Single Field : ->addIndex( $installer->getIdxName( ‘YOUR_TABLE_NAME’, [‘YOUR_UNIQUE_FIELD_NAME’], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), [‘YOUR_UNIQUE_FIELD_NAME’], [‘type’ => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] )   You can also set by multiple option ->addIndex( $installer->getIdxName( ‘catalog_product_entity_datetime’, [‘entity_id’, ‘attribute_id’, ‘store_id’], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), [‘entity_id’, ‘attribute_id’, ‘store_id’], [‘type’ => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] )  

PDOException::(“SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes”) in Laravel install

While installing Laravel found the following Error : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)) Why this Happen : According to the Laravel Docs, this problem occurs if you’re using MariaDB or MySQL versions […]

Screenshots and screencasts in Ubuntu

Take a screenshot Keyboard shortcuts Prt Scrn to take a screenshot of the desktop. Alt+Prt Scrn to take a screenshot of a window. Shift+Prt Scrn to take a screenshot of an area you select. automatically saved in your Pictures folder If you do not have a Pictures folder, the images will be saved in your home folder […]

php bin/magento An exception was raised while creating “Request”; no instance returned Magento 2

Check PHP version first : php -v PHP 7.3.3-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Mar 7 2019 20:31:26) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.3-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies equaltrue@server:~/domains/demo.equaltrue.com/public_html/m2/wc/ms230$ Cause: in my case, my Magento 2 version […]

SQLSTATE[HY000] [1698] Access denied for user ‘root’@’localhost’. Tried everything

Method 1: $sudo mysql -u root [mysql] use mysql; [mysql] update user set plugin=” where User=’root’; [mysql] flush privileges; [mysql] \q   If Still not get Work Try this: /etc/init.d/mysql stop mysqld_safe –skip-grant-tables & mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD(”YOUR_PASSWORD”) where user=’root’; mysql> flush privileges; […]

Problem Setting Production Mode – Deploying Static Content – error shows if different locale

While setting Production Mode, Following error shows. Command returned non-zero exit code: Command returned non-zero exit code: `/usr/bin/php7.0 -f /var/www/mage2/public_html/bin/magento setup:static-content:deploy -f en_GB en_US` Change the mode and skip the compilation: php magento deploy:mode:set production –skip-compilation And once the mode is switched you can deploy static content with GB locale. […]