Dies ist eine alte Version des Dokuments!
— slack 11.0 2007-06-26 , slack 12.0 2007-10-18
According to /etc/rc.d/rc.mysqld
do the following:
su - # become user 'root' chmod +x /etc/rc.d/rc.mysqld # start mysqld at every boot mysql_install_db --user=mysql # install inital database (/var/lib/mysql) /etc/rc.d/rc.mysqld start # start mysqld
Get your values for <yourHostName> and <yourDomainName> with hostname -f
The command mysql_install_db
(see above) strongly recommends to setup a root password:
su - # become user 'root' mysqladmin -u root password <yourPassword> #mysqladmin -u root -h <yourHostName> password <yourPassword>
Don't issue the second command, it fails, because of 2 independent reasons:
We don't care about this quirk and just delete all rows from the table mysql/user which contain <yourHostName> as host:
pager most; USE mysql; SELECT * FROM USER; # TO CHECK DELETE FROM USER WHERE host='<yourHostName>'; FLUSH privileges; SELECT * FROM USER; # TO CHECK
The follwing is obsolete since 2007-10-18 (Slack 12.0)
Comment out the line SKIP=„–skip-networking“
in /etc/rc.d/rc.mysqld
and restart mysqld with /etc/rc.d/rc.mysqld resart
. Log into the monitor with mysql -u root -p
, then issue the following commands:
pager most; USE mysql; SELECT * FROM USER; # TO CHECK UPDATE USER SET host='<yourHostName>.<yourDomainName>' WHERE host='<yourHostName>'; FLUSH privileges; SELECT * FROM USER; # TO CHECK
Now the command mysqladmin -u root -h <yourHostName> password <yourPassword>
should work
Comment in the line SKIP=„–skip-networking“
in /etc/rc.d/rc.mysqld
again and restart mysqld with /etc/rc.d/rc.mysqld resart
again.
mysql -u username -p # log into mysql
PAGER most; /* or */ PAGER less; # Redirect output TO a pager NOPAGER; # Switch off redirection SHOW DATABASES; # Display the availabel databaese ON the server USE myDatabase; # Subsequent commands refer TO myDatabase
/* Create a database with name myDb. Shell alternative: mysqladmin create myDb */ CREATE DATABASE myDb; /* Create a user for the new datase with all possible access privileges. Affects mysql.user and mysql.db ' is important for password! */ GRANT ALL PRIVILEGES ON myDb.* TO myUser@localhost IDENTIFIED BY 'myPassword'; /* Alternative to create a user: */ CREATE USER td_ps_user@localhost IDENTIFIED BY 'myPassword'; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON td_ps.* TO td_ps_user@localhost; /* Delete the database with all tables. */ DROP DATABASE myDb;
SHOW TABLES; # SHOW ALL TABLES OF a dababase DESCRIBE myTable; # SHOW COLUMN DATA types OF a TABLE RENAME TABLE oldname TO newname; /* To alter the data tye of a column or eg to remove auto_increment. */ ALTER TABLE myTable MODIFY myColumn MEDIUMINT UNSIGNED; /* Delete Tables */ DROP TABLE [IF EXISTS] myTable [, my2ndTable, ...] [RESTRICT | CASCADE]
SELECT * FROM myTable; # SHOW content OF a TABLE /* Query 2 tables at the same time (see 3.6.6. Using Foreign Keys) */ SELECT a.*, b.myCol1 FROM myTabA a INNER JOIN myTabB b ON a.id = b.a_id WHERE ...; /* To test for NULL, you cannot use the arithmetic comparison operators such as =, <, or <> */ SELECT * FROM myTable WHERE myColumn IS NULL; SELECT COUNT(*) FROM myTable; # Shows the NUMBER OF LINES OF a TABLE TRUNCATE myTable; # DELETE ALL ROWS OF a TABLE, LIKE DELETE, but faster /* Delete rows with conditions */ DELETE [LOW_PRIORITY] FROM myTable [WHERE where_definition] [LIMIT ROWS]
mysqldump --opt dbname # Backup a Database mysql db_name < backup-file.sql # Restore the Database mysqldump [--opt] --all_databases > file # Backup all Databases
backup-file.sql
is encoded in UTF-8 (use eg. file backup-file.sql
)DEFAULT CHARSET=utf8
in CREATE TABLE
sections of backup-file.sql
collate latin1_german2_ci
mysqldump
inserts funny comments which seem to mess with the character set when imported. ⇒ Remove all comments in backup-file.sql
pager or \P; nopager or \pager on/off, wich pager to use is set in ??? env-variable INSERT INTO tabelname SET colname1=('c1val1'), ...; Es müssen nicht alle Spalten angegeben werden INSERT INTO urlConnector VALUES (2, 1); alle Spalten müssen angegben werden; NULL wenn kein Wert vorliegt mysql -u user --pager="less -S" database Als Benutzer user in die Datenbank database einloggen. Output geht nach less, und Zeilen werden nicht umgebrochen Wenn man schon eingeloggt ist, kann man das gleiche erreichen mit "mysql> \P less -S" -t Output in table format (for batch mode) -vvv very verbose (for batch mode ?) -? show all command line options (unlike 'man mysql' or the manual) --pager use pager set in $PAGER environment variable varchar(<länge>) Datentyp String date Datentyp Datum load data infile "<dateiname>" into table <table>; Daten aus einer Textdatei tabgetrennt in die Tabelle laden