|
1 |
watch -n 1 --differences "mysql -u username -pPassword -e 'show processlist'" |
|
1 |
watch -n 1 --differences "mysql -u username -pPassword -e 'show processlist'" |
|
1 2 |
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES; |
Move a complete MySQL Database to a new Server
You can even rename the database, just use another database name on the remote server.
Dump the database direct to the remote mysql server
|
1 |
mysqldump --extended-insert --force --log-error=mysql_dump_error.log -u <username> -p'<password>' <database> | mysql -h <server host/ip> -u <username> -p'<password>' <database> |
Use ssh if you do not have direct access to the remote mysql server. (Secure)
|
1 |
mysqldump --extended-insert --force --log-error=mysql_dump_error.log -u <username> -p'<password>' <database> | ssh -C <ssh_user>@<server host/ip> "mysql -u <username> -p'<password>' <database>" |
Move a complete MySQL Server to a new Server
Dump all databases direct to the remote mysql server
|
1 |
mysqldump --extended-insert --force --log-error=mysql_dump_error.log -u <username> -p'<password>' --all-databases | mysql -h <server host/ip> -u <username> -p'<password>' |
Use ssh if you do not have direct access to the remote mysql server. (Secure)
|
1 |
mysqldump --extended-insert --force --log-error=mysql_dump_error.log -u <username> -p'<password>' --all-databases | ssh -C <ssh_user>@<server host/ip> "mysql -u <username> -p'<password>'" |
So you wanted to change the value of “innodb_log_file_size” on your mysql server.
As it happens, you can’t just change it the “my.cnf” file, restart and make it work. If you do, Mysql will refuse to start and throw this error instead. You can the details of the startup error in your mysql error log file.
To safely change this setting follow these steps
Restart mysql. Check the error log to make sure everything started successfully, mysql may complain that the log files don’t exist, it will make new ones and start.
Make sure if you are changing things on a production server, you take due care of the mysql downtime due to the changes and restart, and have backups to recover quickly in case something goes wrong.
Kleines Snippet um Unix Timestamps in einer Tabelle in Datetime umzuwandeln
|
1 2 3 4 |
ALTER TABLE `table1` CHANGE `time` `unix_time` int(11) NOT NULL /* rename the old column */ ALTER TABLE `table1` ADD `time` DATETIME NOT NULL /* create the datetime column */ UPDATE `table1` SET `time`=FROM_UNIXTIME(unix_time) /* convert the data */ ALTER TABLE `table1` DROP `unix_time` /* drop the old unix time column */ |
Nach einem Update von MySQL bekam ich folgende Fehlermeldung, wenn ich mit MySQL Workbench die DB Schemas updaten wollte:
|
1 |
Cannot load from mysql.proc. The table is probably corrupted |
Dafür gibt es eine einfache Lösung:
|
1 |
mysql_upgrade |
Auf dem Server ausführen, unter Windows findet man diese Datei unter
|
1 |
<MySQL>/bin/mysql_upgrade.exe |
Wenn man diese ausgeführt hat, sollte alles wieder funktionieren.
Hier eine kleine Abfrage, um Doppelte Einträge aus einer Tabelle zu löschen:
|
1 2 3 4 5 6 |
DELETE FROM table1 USING table1, table1 as vtable WHERE (table1.ID > vtable.ID) /* Hier wird der erste Eintrag beibehalten */ /*(table1.ID < vtable.ID)*/ /* Hier wird der letzte Eintrag beibehalten */ AND (table1.field_name=vtable.field_name) |
table1: Tabellenname
field_name: Feld welches zum vergleichen genutzt werden soll
Die WHERE Clause kann man beliebig erweitern.
Wenn man diese Fehlermeldung von einem MySQL Server zurück bekommt, sollte man erstmal überprüfen ob die Spalten welche für die Foreign Keys genutzt werden, die selben Datentypen sind:
Zu prüfende Werte:
Heute wollte mein MySQL Workbench nicht mehr per SSH auf einen MySQL Server verbinden, ich bekam nur folgende Fehlermeldungen
|
1 2 3 |
62842 INFO Connecting to SSH server at SERVER:22 using key <public_rsa>... 62842 ERROR Failed to connect to SERVER:22: WindowsError(5, 'Zugriff verweigert') Operation failed: Error connecting SSH tunnel: [Error 5] Zugriff verweigert: 'PFAD\\temp\\tmpqpodwu.pag' |
Mit dem selben SSH Key kann ich aber wunderbar mit Putty auf den Server verbinden.
Das Problem war, das ich einen RSA Key benutze.
Die Lösung, einfach den RSA Key mit PuTTYgen in einen DSA Key umwandeln.