M
M
Maxim2017-11-28 22:03:40
C++ / C#
Maxim, 2017-11-28 22:03:40

Mistake. How to make a migration in yii2?

It used to work, but now it gives errors. As I understand that the problem is in connecting to the database. Tell me where to dig the error and what's wrong) I'm doing migrations on localhost

Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2002] No such file or directory'

in /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Connection.php:597

Stack trace:
#0 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Connection.php(943): yii\db\Connection->open()
#1 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Connection.php(930): yii\db\Connection->getMasterPdo()
#2 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Command.php(243): yii\db\Connection->getSlavePdo()
#3 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Command.php(1062): yii\db\Command->prepare(true)
#4 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Command.php(386): yii\db\Command->queryInternal('fetchAll', NULL)
#5 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/mysql/Schema.php(320): yii\db\Command->queryAll()
#6 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/mysql/Schema.php(111): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Schema.php(662): yii\db\mysql\Schema->loadTableSchema('migration')
#8 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/db/Schema.php(173): yii\db\Schema->getTableMetadata('{{%migration}}', 'schema', true)
#9 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/console/controllers/MigrateController.php(204): yii\db\Schema->getTableSchema('{{%migration}}', true)
#10 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(875): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#11 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(166): yii\console\controllers\BaseMigrateController->getNewMigrations()
#12 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#13 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#15 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/console/Controller.php(144): yii\base\Controller->runAction('', Array)
#16 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#17 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#18 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#19 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#20 /Users/maksimvorozcov/.bitnami/stackman/machines/xampp/volumes/root/htdocs/crm-sd/yii(31): yii\base\Application->run()
#21 {main}

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Space Purr, 2019-09-13
@turchik2808

1. It's better to start with YouTube. See with your eyes how people generally work in Visual Studio.
2. After studying the basic things on YouTube: cycles, types, conditions, visibility of variables, you can go to the book.
3. Recommend Andrew Troelsen C# 7 Programming Language and .NET Platforms and .Net Core 8th Edition (2018).

A
Alexander +, 2019-09-12
@AlexanderMi

https://metanit.com/sharp/tutorial/

M
Maxim Isaev, 2019-09-12
@MaximIs

I highly recommend this excellent C# course. ulearn.me

M
Maksim, 2017-12-01
@myks92

- root is usually root, but just in case, check if he has rights to the crm database
- each root from the list is a different user, i.e. [email protected] and [email protected] are different users and, accordingly, they may have different rights to the database, different passwords, etc.
- try to connect with each
one - check if the MySQL server is on the same server as your webserver with php (banal, but still). This is the same MySQL server you are trying to connect to, or maybe your crm database is spinning somewhere else
- check for crm database files on the server
- the allow local access only settings have nothing to do with it
- the problem may be in using a socket for the MySQL process, try using port 3306 instead of a socket in the MySQL server settings
- xampp is the best solution (apache + php + mysql) for developing on Windows that I have met (and I have met almost all of them))) , but if you understand how the components are configured and connected, then for you the question will not be in choosing a ready-made solution
- with what account do you connect to phpMyAdmin (host (url), login, password)
- try connecting to mysql from the console (remote and local) which accounts can connect
- and finally check the disk space quotas for the crm database. Or whether there is still free space on the disk.

M
Maxim Timofeev, 2017-11-29
@webinar

Most often it helps to demolish "xampp" and use "openServer". But if you also have a mac - then welcome to the club of masochistic progers. I would give it to some designer (for whom it was made) and buy something better. Well, it's a lyric.
Dig mysql settings, especially allow local access only

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question