Hallo Leute,
für mein Projekt einer Wettermessstation (WS2500) installiere ich gerade verschiedene Programme auf meinem RaspberryPi+. Nach ein paar Anläufen habe ich jetzt den RbP+ endlich im LAN und Verbindungen via SSH, VNC und SFTP eingerichtet. Für die eigentliche Wettermessstation habe ich verschiedene benötigte Programme installiert: gnuplot, den Webserver Apache2 (It work's), die Datenbank MySQL, sowie phpmyadmin. Das funktioniert soweit. Ich komme auch als root in die Datenbank hinein (siehe spoiler).
Spoiler anzeigen
pi@raspberrypi ~ $ mysql -V
mysql Ver 14.14 Distrib 5.5.40, for debian-linux-gnu (armv7l) using readline 6.2
pi@raspberrypi ~ $ mysql -u "root" -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 61
Server version: 5.5.40-0+wheezy1 (Debian)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quit
Bye
pi@raspberrypi ~ $
Jetzt der nächste Schritt:
Ich habe ein Script "runinstall" für die Wetterstation das mir die Einrichtung der Station softwareseitig weitestgehend abnimmt. Das Script ist alt aber ich habe es 2005 schon mal auf einem SuSE-System zum Laufen gebracht. Es legt Verzeichnisse an, speichert verschiedene weitere Scripte ab usw. Dann fragt es auch das Administratorpasswort für die MySQL-Datenbank ab um sich in die DB einzuloggen und verschieden Tabellen usw. anzulegen.
Dabei bricht es mit folgender Meldung ab:
Now I try to setup the database .....
Testing if MYSQl server is alive and if root access works ...
Database admin has no password. Setting the user specified
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Password could not be set. Stop.
Ich habe einen Administrator nämlich root für die Datenbank und er hat ein Passwort und ich komme damit rein (siehe Spoiler oben), übrigens auch über einen Browser im LAN mittels phpmyadmin.
Also habe ich mal in das Script geschaut was das so macht:
echo "Now I try to setup the database ....."
echo "Testing if MYSQl server is alive and if root access works ..."
$MYSQLADMIN -u root -h "$MYSQLHOST" ping > /dev/null 2>&1
if [ $? = "0" ]; then
echo "Database admin has no password. Setting the user specified"
$MYSQLADMIN -u root -h "$MYSQLHOST" password "$DBADMINPW"
if [ $? != "0" ]; then
echo "Password could not be set. Stop."
exit 1
else
echo "New DBadmin password set successfully."
fi
fi
$MYSQLADMIN -u root -p"$DBADMINPW" -h "$MYSQLHOST" ping
if [ $? != "0" ]; then
cat <<EOF
Access to MYSQL server "$MYSQLHOST" with user root was not successful.
Please check that your server is running, the password you gave above
for the MYSQl admin user is correct and check if this works and then
restart this script. You can check if your data are correct by running
"mysqladmin" in a command shell. The complete commandline is:
$MYSQLADMIN -u root -p"$DBADMINPW" -h "$MYSQLHOST" ping
If this command has a return Status == 0 access is OK. Keep the
parameters you found (password, server name) in mind and restart this
script.
EOF
exit 1
else
echo
echo "Access to MYSQl server is OK"
fi
Alles anzeigen
Das Schript versucht mit dem Befehl mysqladmin in die Datenbank zu kommen. Ich habe die manpage gelesen, verstehe aber nicht wieso das Script nicht mit mysql arbeitet sondern mit mysqladmin! :s
Wenn ich den Befehl selber eintippe, passiert auf der Konsole folgendes:
pi@raspberrypi ~ $ mysqladmin -u root -h "localhost" ping
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using passwort: NO)'
pi@raspberrypi ~ $
Also die Datenbank ist am Laufen, okay. Der root kommt aber nicht rein weil er kein Passwort braucht? Ist der root für mysqladmin ein anderer als der root für mysql?
Also was mache ich falsch, bzw. was muss ich tun, damit das script durchläuft?
Viele Grüße
Clint