Skip to main content
3 votes
Accepted

How do I get connection to database by entering Database details in Magento 2?

You can use default Magento MysqlFactory this way (outside the magento): <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); ini_set('memory_limit', '5G'); error_reporting(...
Siarhey Uchukhlebau's user avatar
2 votes
Accepted

How to execute multiple DB queries?

Try something like this: private ?AdapterInterface $connection = null; private method doMultipleQueriesAndDoUnlockNoMatterWhat(): void { $query1 = sprintf('LOCK TABLE %s WRITE', $tablename); $...
Max's user avatar
  • 309
2 votes

Magento 2: installation command not working

Found Solution for issue db need to be clean using --cleanup-database attribute in installation command php bin/magento setup:install --base-url=http://magento2.com/ --db-host=localhost --db-name=...
Paras Arora's user avatar
2 votes

DATABASE RELATED ERROR" SUCH AS SQLSTATE[HY000][2002]

You probably have wrong credential in your env.php for the database. Try to connect first to your database without magento.
Claims's user avatar
  • 1,231
1 vote
Accepted

Magento and MySQL: Access denied for user 'username'@'localhost' (using password: YES)

Maybe try to use 127.0.0.1 instead of localhost in app/etc/env.php
Adarsh Khatri's user avatar
1 vote

How to properly replace database in Magento 2?

The following steps, you need to perform to properly replace the database: Change connectivity parameters for the new database in app/etc/env.php Check and correct base URLs in the core_config_data ...
Mohit Kumar Arora's user avatar
1 vote

How do I get connection to database by entering Database details in Magento 2?

create a custom PHP script file in Magento setup root folder and from Magento "env.php" file you can get database details like this. $env = require_once(__DIR__.'/app/etc/env.php'); $env = $env['db'][...
Shailesh Katarmal's user avatar
1 vote

How to create a complete group tab to admin?

try following way.. In file app/code/local/Namesapce/Modulename/etc/system.xml <general> <groups> <test translate="label"> &...
Rakesh Donga's user avatar
  • 5,394
1 vote

Magento 2.2 - Fatal error: Uncaught Error: Call to undefined method Magento\Framework\App\ResourceConnection::load()

It looks like you are trying to do sql queries from within class. Need to do something like this public function __construct( \Magento\Framework\App\ResourceConnection $resource ) { $this-&...
Dominic Pixie's user avatar
1 vote

How to recover env.php file in Magento 2?

You need to find out about your hosting. If working on host might be worth reaching out to host to see if they have a restore procedure in place. The fact that you know what file and when you deleted ...
Dominic Pixie's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible