MySQL

Vor dem ersten Start des Servers

Bevor man den Mysql-Server das erste mal startet, sollte man das Verzeichnis /var/lib/mysql/mysql löschen. Danach dann (als User root):

mysql_install_db --user=mysql

Hierdurch wird die "mysql"-Datenbank neu erstellt.

Setzen des "root"-Passwortes

Als nächstes sollte man das "root"-Passwort setzten:Wie man das Root-Passwort bei mysql setzt

Ablauf von SQL-Scripten

Die drupal-Datenbank, die man bei 1und1 entladen hat (liegt unter /data/data1/israel-network/db40.puretec.de.sql), kann man als User "cw" mit dem Befehl

mysql < db40.puretec.de.sql

der mysql-Instanz hinzufügen.

Rechtevergabe an den Drupal-Datenbankuser

In diesem Falle der User 'cw', root ruft mysql auf und vergibt dann das Recht:

grant all on db181829985.* to 'cw'@'localhost' identified by 'blablabla';

Erst nach diesem Statement kann der User cw mittels mysql auf die Datenbank zugreifen. Zuvor bekam 'cw' immer eine Fehlermeldung:

cw@gisevius:~> mysql -p db181829985
Enter password:
ERROR 1045 (28000): Access denied for user 'cw'@'localhost' (using password: YES)

Die Ausgabe des show grants Statements ist irreführend:

mysql> show grants for cw;
+---------------------------------------------------------------------------------------------------+
| Grants for cw@%                                                                                   |
+---------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'cw'@'%' IDENTIFIED BY PASSWORD '*A1E2A5ED8A153592D333B5AECA9783EA238D6AD6' |
| GRANT ALL PRIVILEGES ON `db181829985`.* TO 'cw'@'%' WITH GRANT OPTION                             |
+---------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

GUI zum Administrieren

Eine gute GUI zum Administrieren bekommt man mit /usr/bin/mysql-administrator.



Mysql Fehler

Starting service MySQL warning: /var/lib/mysql/mysql.sock didn't appear within 30 seconds

Wenn diese Meldung nach dem "rcmysql start" kommt, dann zuerst das Logfile prüfen: /var/log/mysql.log.
Hier könnte zum Beispiel folgendes stehen:


090401 08:33:13  mysqld started
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
090401  8:33:13  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Page directory corruption: supremum not pointed to
090401  8:33:13  InnoDB: Page dump in ascii and hex (16384 bytes):

In diesem Falle einfach die Dateien /var/lib/mysql/ibdata_1 und /var/lib/mysql/ib_logfile1 (oder "0" am Ende)
löschen:

rm ibdata* ib_logfile*

und danach neu starten.



Wie man das Root-Passwort bei mysql setzt


http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

In a Unix environment, the procedure for resetting the MySQL
root password is as follows:

  1. Log on to your system as either the Unix
    root user or as the same user that
    the mysqld server runs as.

  2. Locate the .pid file that contains

    the server's process ID. The exact location and name of
    this file depend on your distribution, hostname, and
    configuration. Common locations are
    /var/lib/mysql/,
    /var/run/mysqld/, and
    /usr/local/mysql/data/. Generally,
    the filename has the extension of
    .pid and begins with either
    mysqld or your system's hostname.

    You can stop the MySQL server by sending a normal
    kill (not kill -9)
    to the mysqld process, using the
    pathname of the .pid file in the
    following command:

    shell> kill `cat /mysql-data-directory/host_name.pid`
    
    

    Note the use of backticks rather than forward quotes
    with the cat command; these cause the
    output of cat to be substituted into
    the kill command.

  3. Create a text file and place the following command
    within it on a single line:

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPassword');
    

    Save the file with any name. For this example the file
    will be ~/mysql-init.

  4. Restart the MySQL server with the special
    --init-file=~/mysql-init option:

    shell> mysqld_safe --init-file=~/mysql-init &
    

    The contents of the init-file are executed at server
    startup, changing the root password. After the server
    has started successfully you should delete
    ~/mysql-init.

  5. You should be able to connect using the new password.

Alternatively, on any platform, you can set the new password
using the mysql client(but this approach
is less secure):

  1. Stop mysqld and restart it with the
    --skip-grant-tables --user=root options
    (Windows users omit the --user=root

    portion).

  2. Connect to the mysqld server with
    this command:

    shell> mysql -u root
    
  3. Issue the following statements in the
    mysql client:

    mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd')
        ->                   WHERE User='root';
    
    mysql> FLUSH PRIVILEGES;
    

    Replace “newpwd
    with the actual root password that

    you want to use.

  4. You should be able to connect using the new password.

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
CAPTCHA
Diese Frage dient dazu festzustellen, ob Sie ein Mensch sind und um automatisierte SPAM-Beiträge zu verhindern.
9 + 8 =
Lösen Sie dieses einfache mathematische Problem und geben Sie das Ergebnis ein. Für 1 + 3 geben Sie z.B. 4 ein.