By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,748 Members | 1,506 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,748 IT Pros & Developers. It's quick & easy.

php cli

P: n/a
hi,

can anyone tell me how to configure php cli with mysql support? i;ve
tried adding defaul username, password and host in /etc/php5/cli/
php.ini but this didnt work.

php-m does not list mysql.

php version is 5.1.6 running on Ubuntu 6.10 with Apache/2.0.55

many thanks,

lukemack.

Jan 27 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
lukemack wrote:
hi,

can anyone tell me how to configure php cli with mysql support? i;ve
tried adding defaul username, password and host in /etc/php5/cli/
php.ini but this didnt work.

php-m does not list mysql.

php version is 5.1.6 running on Ubuntu 6.10 with Apache/2.0.55

many thanks,

lukemack.
PHP doesn't know where the ini file is when run from the cli, so your
MySQL (or any other) extension is never getting loaded.

Try:
php -c /path/to/php.ini

Note this doesn't have to be the same one that Apache uses.
Jan 27 '07 #2

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Carl Pearson wrote:
PHP doesn't know where the ini file is when run from the cli,
Yes, it does:
ivan@littlespark:~$ echo "<?php phpinfo(); ?>" | php5 | grep ini

Configuration File (php.ini) Path =/etc/php5/cli/php.ini
Scan this dir for additional .ini files =/etc/php5/cli/conf.d
additional .ini files parsed =/etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/ldap.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/odbc.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
/etc/php5/cli/conf.d/pdo_odbc.ini,
/etc/php5/cli/conf.d/pdo_sqlite.ini,
/etc/php5/cli/conf.d/sqlite.ini

So you have to make sure that /etc/php5/cli/php.ini loads the mysql.so
extension.
- --
- ----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/
Proudly running Debian Linux with 2.6.17-1-686 kernel, KDE3.5.3, and PHP
5.2.0-8 generating this signature.
Uptime: 23:41:51 up 1 day, 10 min, 1 user, load average: 0.10, 0.11, 0.09

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFu9VwR56dWuhgxGgRAs55AKCqL3uefV8RY/cuy9Y0m0iF0CEwDwCfc94z
OmCucl+TBTyirDeCZpGb9W0=
=aeQv
-----END PGP SIGNATURE-----
Jan 27 '07 #3

P: n/a
thanks - i edited php.ini to load mysql.ini and it works now.

thanks for your help,

lukemack.

On 27 Jan, 22:42, Ivn Snchez Ortega <ivansanche...@rroba--
escomposlinux.punto.netwrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Carl Pearson wrote:
PHP doesn't know where the ini file is when run from the cli,Yes, it does:

ivan@littlespark:~$ echo "<?php phpinfo(); ?>" | php5 | grep ini

Configuration File (php.ini) Path =/etc/php5/cli/php.ini
Scan this dir for additional .ini files =/etc/php5/cli/conf.d
additional .ini files parsed =/etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/ldap.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/odbc.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
/etc/php5/cli/conf.d/pdo_odbc.ini,
/etc/php5/cli/conf.d/pdo_sqlite.ini,
/etc/php5/cli/conf.d/sqlite.ini

So you have to make sure that /etc/php5/cli/php.ini loads the mysql.so
extension.

- --
- ----------------------------------
Ivn Snchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/
Proudly running Debian Linux with 2.6.17-1-686 kernel, KDE3.5.3, and PHP
5.2.0-8 generating this signature.
Uptime: 23:41:51 up 1 day, 10 min, 1 user, load average: 0.10, 0.11, 0.09

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFu9VwR56dWuhgxGgRAs55AKCqL3uefV8RY/cuy9Y0m0iF0CEwDwCfc94z
OmCucl+TBTyirDeCZpGb9W0=
=aeQv
-----END PGP SIGNATURE-----
Jan 28 '07 #4

P: n/a
lukemack wrote:
thanks - i edited php.ini to load mysql.ini and it works now.
Uhm, MySQL wasn't working in Apache either? You never mentioned that.

MySQL should have already been loading in php, you were talking about
CLI usage like it was giving you different behavior, so I was thinking
it was a path problem (php not finding the ini). Sorry for the
misunderstanding.
Jan 28 '07 #5

P: n/a
i was talking about cli only. slight typo there - should have said
mysql.so in the php.ini in the cli folder. i did mean cli
functionality only - mysqsl was working fine in apache.

On 28 Jan, 15:01, Carl Pearson <jman_spam_trap_....@gmail.comwrote:
lukemack wrote:
thanks - i edited php.ini to load mysql.ini and it works now.Uhm, MySQL wasn't working in Apache either? You never mentioned that.

MySQL should have already been loading in php, you were talking about
CLI usage like it was giving you different behavior, so I was thinking
it was a path problem (php not finding the ini). Sorry for the
misunderstanding.
Jan 30 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.