MySQL: Unterschied zwischen den Versionen

Aus Tutorials
Zur Navigation springen Zur Suche springen
Zeile 60: Zeile 60:
word-wrap: break-word;">
word-wrap: break-word;">
mysql> create user '<username>'@'%' identified by '<password>';
mysql> create user '<username>'@'%' identified by '<password>';
mysql> grant usage on *.* to '<username>'@'%' identified by '<password>';  
mysql> grant (all|select|...) on (*|<database>).* to '<username>'@'%';  
</pre>
</pre>


Zeile 70: Zeile 70:
word-wrap: break-word;">
word-wrap: break-word;">
mysql> create user '<username>'@'localhost' identified by '<password>';
mysql> create user '<username>'@'localhost' identified by '<password>';
mysql> grant usage on *.* to '<username>'@'localhost' identified by '<password>';  
mysql> grant (all|select|...) on (*|<database>).* to '<username>'@'localhost';  
</pre>
</pre>



Version vom 13. April 2016, 23:39 Uhr

Datenbanken eines MySQL-Servers auflisten:

mysqlshow -u <user name> -p[<password>]

Tabellen und Felder auflisten

mysql -u <user name> -p
mysql> use <database>;
mysql> show tables from <database>;
mysql> show fields from <table_name>;
mysql> quit;

Backup einer Datenbank anlegen:

mysqldump -u <user name> -p[<password>] <database name> > <dump file name>.sql

Backup einer Datenbank importieren:

mysql -u <user name> -p[<password>] <database name> < <dump file name>.sql

Anmelden am MySQL-Server:

mysql -u <user name> -p[<password>]

Abmelden vom MySQL-Server:

quit;

Neuen Benutzer anlegen:

mysql> create user '<username>'@'%' identified by '<password>';
mysql> grant (all|select|...) on (*|<database>).* to '<username>'@'%'; 

Soll der Zugriff auf localhost beschränkt sein, dann überall localhost anstelle von % verwenden:

mysql> create user '<username>'@'localhost' identified by '<password>';
mysql> grant (all|select|...) on (*|<database>).* to '<username>'@'localhost'; 

Neue Datenbank anlegen:

mysql> create database if not exists <database name>;

Datenbank löschen:

drop database if exists <database name>;

Rechte für Datenbank zuweisen

grant all privileges on <database>.* to '<username>'@'localhost';

Änderungen gültig machen

flush privileges;


Zurück zu Allgemein