Last active
September 30, 2019 10:01
-
-
Save joseluisq/8274fc2fe24e5ba717cbb5547e7e99f8 to your computer and use it in GitHub Desktop.
Revisions
-
joseluisq revised this gist
Jun 5, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ # MySQL helpful commands and scripts > Some useful commands and scripts for MySQL. __Update:__ All these commands and more at https://github.com/joseluisq/awesome-mysql-queries-commands ## Import script file from console ```sh -
joseluisq revised this gist
Sep 27, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ mysqldump -h localhost -u username -p database_name > ./mysql_script.sql mysqldump -h localhost -u username -p database_name | gzip > ./mysql_script.sql ``` or using `--single-transaction` if you got an mysqldump error (because you lack privileges to lock the tables) ```sh mysqldump -h localhost -u username -p database_name --single-transaction | gzip > ./mysql_script.sql -
joseluisq revised this gist
Sep 27, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ mysqldump -h localhost -u username -p database_name > ./mysql_script.sql mysqldump -h localhost -u username -p database_name | gzip > ./mysql_script.sql ``` or using --single-transaction if you got an mysqldump error (because you lack privileges to lock the tables) ```sh mysqldump -h localhost -u username -p database_name --single-transaction | gzip > ./mysql_script.sql -
joseluisq revised this gist
Sep 27, 2017 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,12 @@ mysqldump -h localhost -u username -p database_name > ./mysql_script.sql mysqldump -h localhost -u username -p database_name | gzip > ./mysql_script.sql ``` or using `--single-transaction` if you got an error for mysqldump (because you lack privileges to lock the tables) ```sh mysqldump -h localhost -u username -p database_name --single-transaction | gzip > ./mysql_script.sql ``` #### Export tables to SQL file ```sh -
joseluisq revised this gist
Oct 19, 2016 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ ## Import script file from console ```sh mysql -h host -u username -p password --default_character_set utf8 database_name < mysql_script.sql ``` Or on MySQL shell type: @@ -19,23 +19,23 @@ mysql> SOURCE mysql_script.sql #### SQL file ```sh mysqldump -h localhost -u username -p database_name > ./mysql_script.sql ``` #### Export database to SQL + GZIP file ```sh mysqldump -h localhost -u username -p database_name | gzip > ./mysql_script.sql ``` #### Export tables to SQL file ```sh mysqldump -h localhost -u username -p database_name table_name1 table_name2 > mydb_tables.sql ``` ## Finding duplicated values ```sql SELECT code, COUNT(code) duplicates FROM client GROUP BY code HAVING duplicates > 1; ``` -
joseluisq revised this gist
Aug 12, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,8 +34,8 @@ $ mysqldump -h localhost -u username -p database_name | gzip > ./mysql_script.sq $ mysqldump -h localhost -u username -p database_name table_name1 table_name2 > mydb_tables.sql ``` ## Finding duplicated values ```sql SELECT code, COUNT(code) duplicates FROM client GROUP BY code HAVING duplicates > 1; ``` -
joseluisq created this gist
May 23, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ # MySQL helpful commands and scripts > Some useful commands and scripts for MySQL. ## Import script file from console ```sh $ mysql -h host -u username -p password --default_character_set utf8 database_name < mysql_script.sql ``` Or on MySQL shell type: ```sh mysql> USE DATABASE mydatabase_name; mysql> SOURCE mysql_script.sql ``` ## Export script file from console #### SQL file ```sh $ mysqldump -h localhost -u username -p database_name > ./mysql_script.sql ``` #### Export database to SQL + GZIP file ```sh $ mysqldump -h localhost -u username -p database_name | gzip > ./mysql_script.sql ``` #### Export tables to SQL file ```sh $ mysqldump -h localhost -u username -p database_name table_name1 table_name2 > mydb_tables.sql ``` ## Finding duplicate values ```sql SELECT code, COUNT(*) duplicates FROM table_name GROUP BY code HAVING duplicates > 1; ```