Mysql: Unterschied zwischen den Versionen

Aus Info-Theke
Zur Navigation springen Zur Suche springen
Zeile 8: Zeile 8:
mysql -u root -p mysql
mysql -u root -p mysql
grant all on *.* to 'debian-sys-maint'@'localhost' identified by "6QLw8BSKFwzDnoUT";
grant all on *.* to 'debian-sys-maint'@'localhost' identified by "6QLw8BSKFwzDnoUT";
grant all on *.* to 'dbadmin'@'192.168.2.%' identified by '6QLw8BSKFwzDnoUT';
grant all on mydb.* to 'dbadmin'@'192.168.2.%' identified by '6QLw8BSKFwzDnoUT';
grant SELECT on *.* to 'backup'@'localhost' identified by 'SAVE:alls!4711';
grant SELECT on *.* to 'backup'@'localhost' identified by 'SAVE:alls!4711';
flush privileges;
flush privileges;

Version vom 28. Januar 2019, 09:47 Uhr


Debian Anpassungen

Debian prüft die Tabellen beim Booten. Damit das funktioniert, muss ein passender User eingerichtet sein:

  • Siehe /etc/mysql/debian.cnf
mysql -u root -p mysql
grant all on *.* to 'debian-sys-maint'@'localhost' identified by "6QLw8BSKFwzDnoUT";
grant all on mydb.* to 'dbadmin'@'192.168.2.%' identified by '6QLw8BSKFwzDnoUT';
grant SELECT on *.* to 'backup'@'localhost' identified by 'SAVE:alls!4711';
flush privileges;

MariaDB: Es ist für root ein Passwort vergeben. Man kann sich aber als OS-User root ohne Passwort anmelden.

Nachträglich Root-Passwort setzen

Wenn bei der Installation das Passwort nicht gesetzt wurde, kann das nachträglich passieren:

update user set 
authentication_string=password('ge:heimesp_w1'),
plugin='mysql_native_password'
where user='root';

Zugriff ohne Root-Passwort (als Benutzer root):

update user set 
authentication_string='',
plugin='auth_socket'
where user='root';

Datentypen

create table example(
   id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
   ts TIMESTAMP NULL default NULL,
   dt DATETIME,
   name VARCHAR(100) UNIQUE NOT NULL
);
  • TIMESTAMP ist normalerweise ohne NULL, Default-Wert ist NOW()