Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to DB, when running via command line

When I run zend framework project from browser, everything is OK, it connects to DB.

When I run project from command line it can't connect to DB and it throws an error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php:129

I have used Running a Zend Framework action from command line 's answers ( https://stackoverflow.com/a/4706966/457033 )

It's my application.ini file's db part

phpSettings.mysql.default_socket=/usr/local/zend/mysql/tmp/mysql.sock

resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.port = 3306
resources.db.params.username = "root"
resources.db.params.password = "root"
resources.db.params.dbname = "iteam"
resources.db.isDefaultTableAdapter = true
resources.db.params.charset = "utf8"
like image 329
hhs Avatar asked Dec 07 '11 11:12

hhs


People also ask

How do I open a database in terminal?

To access a specific database, type the following command at the mysql> prompt, replacing dbname with the name of the database that you want to access: Copy use dbname; Make sure you do not forget the semicolon at the end of the statement. After you access a database, you can run SQL queries, list tables, and so on.

How do I connect to a database server?

Connect to a SQL Server instanceStart SQL Server Management Studio. The first time you run SSMS, the Connect to Server window opens. If it doesn't open, you can open it manually by selecting Object Explorer > Connect > Database Engine. For Server type, select Database Engine (usually the default option).


1 Answers

Copy the content of application.ini in your php.ini file, this should work fine.

like image 102
belgther Avatar answered Sep 24 '22 14:09

belgther