PHP Forum

PHP Forum (http://www.selfphp.de/forum/index.php)
-   MySQLi/PDO/(MySQL) (http://www.selfphp.de/forum/forumdisplay.php?f=22)
-   -   mysql_query("SHOW DATABASES") ohne Connection?!? (http://www.selfphp.de/forum/showthread.php?t=8248)

chris17 23.07.2004 15:50:24

mysql_query("SHOW DATABASES") ohne Connection?!?
 
Hallihallo,

ist das "normal", daß diese Zeilen ohne mysql_connect() funktionieren?
PHP-Code:

$res mysql_query("SHOW DATABASES");

while (
$row mysql_fetch_assoc($res)) {
    echo 
$row['Database'].'<br>';
    
$res_t mysql_query("SHOW TABLES FROM {$row['Database']}");
    while (
$row_t mysql_fetch_row($res_t)) {
        echo 
'&nbsp;- '.$row_t[0].'<br>';
    }


(WAMP mit php 4.3.7)

xabbuh 23.07.2004 17:23:42

Scheint so.

Bei mir (WAMP, php 4.3.3) funktioniert es auch ohne mysql_connect().

chris17 29.07.2004 09:39:19

Hallo xabbuh,

Danke für Deine Antwort. Ich find das schon bissl "komisch", dass das funktioniert.
An welcher Einstellung könnte denn das liegen?

Gruss

Christian

xabbuh 29.07.2004 11:34:23

Gute Frage. Vielleicht ist das aber auch standard und nicht veränderbar?!

Gruß Christian

xabbuh 30.07.2004 09:48:02

Habe bei mir in der php.ini gefunden. Vielleicht hilft dir das weiter.


Zitat:

Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
' at MYSQL_PORT.
mysql.default_port =

; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =

; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =

; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo cfg_get_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =

sniechzial 03.08.2004 23:19:14

Hi,

interessante Feststellung die du da gemacht hast... scheint so auch nicht dokumentiert zu sein.

Hab mal etwas rumprobiert, sowohl unter Windows als auch unter Linux.
Wenn man mysql_query() aufruft, ohne defaults in der php.ini (wie im ersten Post) und ohne vorheriges connect... versucht php sich mit [WEBSERVER_BENUTZERNAME]@localhost auf mySQL zu verbinden.

Code:

Warning: Access denied for user: 'wwwrun@localhost' (Using password: NO) in /intranet/www/www10013/***/http-docs/lc_test.php on line 9
In deiner Config sind die Benuternamen anscheinend passend und du hast kein Passwort... also gehts.

MfG,
simon

chris17 04.08.2004 11:31:37

Hi,
Zitat:

In deiner Config sind die Benuternamen anscheinend passend und du hast kein Passwort... also gehts.
Ich hätte natürlich schreiben sollen, daß ich für root ein Passwort gesetzt habe.

Aber ich hab mir die DB "mysql" dann doch mal genauer angeschaut. :-)

In der Tabelle "user" hab' ich den Übeltäter ausgemacht.

Dort gibt's (anscheinend standardmässig?!?) einen Eintrag:
Host: localhost
User: LEER
password: LEER
Rechte: Von "Select_priv" bis "Alter_priv" YES

Wenn ich den User bearbeite/lösche, dann funktionert das Skript oben nicht mehr.


Vielen Dank für Eure Antworten

Gruß

Christian


Alle Zeitangaben in WEZ +2. Es ist jetzt 12:05:19 Uhr.

Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.