localhost Datenbank Zugriff unter Mamp Pro

Kirzz

Aktives Mitglied
Thread Starter
Dabei seit
14.11.2009
Beiträge
1.368
Reaktionspunkte
101
Hallo,

ich habe Mamp Pro 2.1.4 unter OS X 10.8.4

Wie greife ich auf eine in Mamp Pro über phpMyAdmin angelegte Datenbank zu? Ich kann die in der config Datei angelegten Daten nicht beantworten:

Code:
<?php
function con() {
	global $conn;
// host ip
$dbhost = 'localhost';

// db user name
$dbuser = '';

// password
$dbpass = '';

// connect to database
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql: '.mysql_error());

// select database
$dbname = 'meineDatenbank';

mysql_select_db($dbname) or die ('error selecting database: '.mysql_error());
}
?>

Als Host habe ich 'localhost' eingetragen, ein Passwort ist lokal nicht vergeben.

Online funktioniert die Datenbank (natürlich mit anderen Zugangsdaten), unter Mamp / MySQL bekomme ich sie nicht zum laufen. Auf PHPMyAdmin habe ich Zugriff, die Datenbank sollte (denke ich) funktionieren.

Ich habe noch nie mit lokalen Datenbanken experimentiert. Wie müssen config-Dateien auf lokalen Maschinen eingerichtet sein?
 
Bei einer standardmäßigen Installation von MySQL wird ein Benutzer "root" eingerichtet. Dieser hat erstmal kein Passwort aber sämtliche Rechte auf dem Datenbankserver. Das Passwort kann man aber setzen. In SQL kann man mit dem GRANT-Befehl neue Nutzer und deren Rechte erstellen. Hilft Dir das weiter?
 
Auf phpMyAdmin greifst Du über http://localhost/phpMyAdmin/ zu, nehme ich an?

User ist "root". Passwort, falls es abgefragt wird, ist ebenfalls "root".
http://stackoverflow.com/questions/...l-password-username-for-phpmyadmin-using-mamp

Falls Du Deine MAMP-Installation von aussen zugänglich machst, solltest Du übrigens zwingend Dein Passwort ändern. Das ist alles andere als trivial. Die offizielle MAMP-Dokumentation greift da ein wenig kurz.

Folgende in den MAMP-Foren gefundene Anleitung hatte ich mir mal in ein Text-Dokument kopiert (als Referenz) und selbst gemäß der Anleitung mein MAMP-Passwort geändert. Funktioniert einwandfrei.



Step 1:
Open the Terminal and change your MySQL password.

/Applications/MAMP/Library/bin/mysqladmin -u root -p password NEWPASSWORD

Where NEWPASSWORD is the password you choose.
Now, the OS will ask you for another password when you change it.
That password is literally root (the default for the running MySQL process you're changing).

*********************

Step 2:
Open this file in a text editor:
/Applications/MAMP/bin/phpMyAdmin/config.inc.php

And at this line nearer the start of the file:
$cfg['Servers'][$i]['password'] = 'root'; // MySQL password (only needed...

Change "root" to the same password you just picked above.

Now, the phpMyAdmin link works, but the Start link pointing to http://localhost:8888/MAMP/index.php won't load.
This is also your default start page from the MAMP application, so double frustration.
One more password to change...

*********************

Step 3:
Fix the index page. Open up:
/Applications/MAMP/bin/mamp/index.php
On this line:
$link = @mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', 'root');

Change the 2nd "root" to the same password as in the previous steps.

One last thing. When you try to shut the thing down, Apache will quit, but MySQL won't. Because there's another location to fix.

*********************

Step 4:
Fix the MySQL shutdown file. Open up:
/Applications/MAMP/bin/stopMysql.sh
This is all that's in there:
# /bin/sh
/Applications/MAMP/Library/bin/mysqladmin -u root -proot
--socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown

Change "root" to the same password as in the previous steps.

*********************

Step 5:
The command that opens the start page is in /Applications/MAMP/bin/mamp/index.php. Open this file in TextEdit, and see if it contains:

$link = @mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', 'root');

The second 'root' is the password for the mysql root account. Replace it with the new mysql root password. The "Open start page" button should now work.

Of course, putting the mysql root password in text files like this is insecure, so think twice about using this fix.

*********************

Step 6:
Open up each of these files in a text editor:

Applications/MAMP/bin/checkMysql.sh
Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
Applications/MAMP/bin/repairMysql.sh
Applications/MAMP/bin/upgradeMysql.sh

Look for the line that contains -u root –proot and change "root" to the same password as in the previous steps.

*********************

Step 7:
Go back to the MAMP application window, and click the button to “stop servers.” Now click the button to “start servers.” Both servers should start
(you should see green lights next to Apache server and MySQL server, and a start page should open in your browser).
 
Zurück
Oben Unten