Aktuelle Seite: Projekte » MySQL manager

MySQL manager

Kommandozeilenprogramm zur Verwaltung von MySQL-Datenbanken und -Benutzern (in PHP)

This tool allows for managing users, databases and access rights on a MySQL database server from the command line. You won’t need graphical user interfaces like MySQL’s Administrator or phpMyAdmin for this simple task. This is especially useful for automated routines like setting up applications or as backend script for a web UI to allow users to manage their own databases. This script, along with a small security wrapper, is used in the clients’ configuration interface at dotforward.de webhosting. Here are some examples of usage:

  • Add a new database “db1”:
    mysqlmgr add database db1
  • Add a new user “alice”, interactively ask for the password and grant reading access to the created database:
    mysqlmgr -a add user alice
    mysqlmgr allow user alice all hosts database db1 read
  • Add a new user “bob” with the password as argument:
    mysqlmgr add user bob password s3cr3t
  • Allow “bob” from all hosts writing/defining access to the created database:
    mysqlmgr allow user bob all hosts database db1 read write define
  • List all users:
    mysqlmgr list users
  • Show all access rights for user “bob”:
    mysqlmgr show user bob
  • Rename user “bob” to “chris”:
    mysqlmgr rename user bob to chris
  • Disallow “chris” to add new data to his database:
    mysqlmgr deny user chris all hosts database db1 insert update
  • Show MySQL version of the server db7.company.com:
    mysqlmgr -h db7.company.com version

You can add or edit user accounts for separate originating hostnames. If none is specified, the host “%” is used, which means “connections from all hosts”. When editing a user account, you must use the same host specification as when you added it. (Think of the username and hostname as a pair that describes the user account.) To modify all user accounts with that name (i.e. for connections from all possible hosts), you can use the argument “all hosts” which effectively applies the operation on all present user accounts. If you don’t want to care about different hostnames, you can always omit this specification.

These management commands are sent to the MySQL server through a superuser connection. This is usually the username “root”. To not always enter root’s MySQL password and specifying the server’s hostname (and port) if non-local, you can edit these default values at the top of the programme file. The default connection parameters (except the password) are displayed in the help message.

Download

Version 20080719 (19. Juli 2008)

[o] mysqlmgr.zip (PHP-Programm im ZIP-Archiv, 6 kB)

Anforderungen

Diese Anwendung benötigt zur Ausführung einen PHP-Commandline-Interpreter (CLI) ab Version 5.0, mit MySQL-Unterstützung, im Pfad /usr/bin/php. Mit leichten Anpassungen bzgl. der ersten Zeile (#!) sollte das Programm auf jeder von PHP unterstützten Plattform, also auch Windows, laufen.

Bekannte Probleme, Aufgaben

  • Revoke all access rights on a deleted database (and table)
  • Support table-level access rights
  • Test and if necessary replace commandline arguments parser code (better version included in the archive)

Änderungen

Version 20080719 (19. Juli 2008)

  • Print newline after asking for a password invisibly

Version 20080405 (5. April 2008)

  • Make typing of the password invisible like it is in ‘su’ – Only supported on Linux! Other OS use the old method.

Version 20060503 (3. Mai 2006)

  • Initial release

Lizenz, Nutzungsbedingungen

Dieses Programm ist „Freeware“. Das bedeutet, dass es für private sowie kommerzielle Nutzung kostenlos ist. Die weitere Verbreitung ist nicht ohne meine Genehmigung gestattet. Ich gebe keine Garantie, auch nicht auf Lauffähigkeit oder Benutzbarkeit. Die Nutzung erfolgt auf eigene Gefahr, ich hafte nicht für Schäden, die durch sachgemäßen oder unsachgemäßen Gebrauch dieses Programms entstehen.

PayPal-Spende

Dieses Programm ist in meiner Freizeit entstanden und kostenlos verfügbar. Ich freue mich über jede noch so kleine finanzielle Anerkennung. Spenden sind in beliebiger Höhe über PayPal möglich. Falls gewünscht wird dein Name in der Spendenliste eingetragen. (Leider kann ich keine Kreditkartenzahlungen annehmen. Bei Fragen schreib mir einfach eine E-Mail.) Wähle einen Betrag, den du spenden möchtest: 5 € (empfohlen), 15 € oder beliebiger Betrag

Ausblenden
Statistik wird geladen...