Skip to main content

Posts

Showing posts with the label MySql

MySQL root account blocked (5.7 root require sudoer), password strength etc

https://sysfiddler.com/mysql-error-1819-hy000-your-password-does-not-satisfy-the-current-policy-requirements/ only_full_group_by https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql https://stackoverflow.com/questions/36864206/sqlstatehy000-1698-access-denied-for-user-rootlocalhost Turns out you can't use the root user in 5.7 anymore without becoming a sudoer. That means you can't just run mysql -u root anymore and have to do sudo mysql -u root instead. That also means that it will no longer work if you're using the root user in a GUI (or supposedly any non-command line application). To make it work you'll have to create a new user with the required privileges and use that instead. https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7/763359#763359 SQL dump data extended insert or not (or batched). Knowing how to dump database properly is useful in robust development or d...

MySQL/MariaDB create view error Illigal mix of collations

https://dba.stackexchange.com/questions/170610/how-to-retrieve-the-query-i-used-to-create-a-view SHOW CREATE VIEW not work since it will dump create command within CONVERT() Example:  CREATE ALGORITHM=UNDEFINED DEFINER=`user`@`%` SQL SECURITY DEFINER VIEW `ViewFollowAndFollowerCount` AS select `t1`.`user_id` AS `user_id`,`t4`.`user_name` AS `user_name`,`t2`.`followCount` AS `followCount`,`t3`.`followerCount` AS `followerCount`,`t1`.`created_at` AS `follow_created_at` from (((`UserFollowData` `t1` left join `ViewFollowCountGroupByUserId` `t2` on((`t1`.`user_id` = `t2`.`user_id`))) left join `ViewFollowCountGroupByFollowUserId` `t3` on((`t1`.`user_id` = `t3`.`follow_user_id`))) left join `UserData` `t4` on((convert(`t1`.`user_id` using utf8mb4) = `t4`.`user_id`))) I got error something like: "Illegal mix of collations " This caused by CONVERT() on dump /export (?) when convert collation ie. to utf8mb4... Detail here https://bugs.mysql.com/bug.php?id=54278 So to f...

Random moments 3

1. Mobile Network or BlackBerry Q10 hotspot block SSH port 22 Today I go to countryside in annual Tet holiday and have to use Mobile Network (3G/4G) for my work. Unfortunately It seem my Mobile Network blocked port 22 or may be my phone BlackBerry Q10 blocked it. I use my Q10 as Mobile hotspot. I have no problem before, so I think it is caused by either BlackBerry software or Internet Provider. My laptop is Macbook Pro 2017 and my VPS service is DigitalOcean So I guess I can serve ssh in different port (ie. 2222). After some search, I end up with serve SSH in both port 22 and 2222 use Digital Ocean (DO) web console. Yeah, It work ! Need inspect more why caused this problem. BB OS or Internet Provider or event MBP. There are some other issues like keyboard problem with DO web console. Some character like '|' not work.  https://www.digitalocean.com/community/questions/i-can-t-type-some-symbols-on-console How special char, symbol called in English ? http://catb.org/j...

run-mysqldump-without-locking-tables, some RDS config privilege, max_allowed_packet...

https://stackoverflow.com/questions/104612/run-mysqldump-without-locking-tables https://dba.stackexchange.com/questions/17367/how-can-i-monitor-the-progress-of-an-import-of-a-large-sql-file https://stackoverflow.com/questions/2016894/how-to-split-a-large-text-file-into-smaller-files-with-equal-number-of-lines mysqldump --net_buffer_length=4096 --create-options --default-character-set="utf8" --host="localhost" --hex-blob --lock-tables --password --quote-names --user="myuser" "mydatabase" "mytable" > mytable.sql https://stackoverflow.com/questions/5013151/how-do-i-limit-the-number-of-results-returned-from-grep https://stackoverflow.com/questions/30658703/how-to-print-the-line-number-where-a-string-appears-in-a-file https://askubuntu.com/questions/1026045/limit-grep-output-to-short-lines 35 I found what the problem was. The MySql variable/parameter explicit_defaults_for_timestamp was OFF on my local machine but ON on my r...

mysql 3 cron backup

http://www.techiecorner.com/1619/how-to-setup-mysqldump-without-password-in-cronjob/ Nhắc lại query tìm cột xuất hiện ở table nào trong DB: SELECT * FROM information_schema.COLUMNS WHERE     TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'table_name' AND COLUMN_NAME = 'column_name' Export data MySQL with condition: mysql -e "select picture from post where picture like 'https://s3%'" -u username-p db_name > trump.txt Lệnh trên dump hết picture (url) lưu trên amazon S3 ra file với điều kiện là URL ảnh phải bắt đầu = https://s3 (ko lẫn với các ảnh khác) .

Commands 2

How To Create a New User and Grant Permissions in MySQL Tags:  MySQL What the  Red  Means The lines that the user needs to enter or customize will be in  red  in this tutorial! The rest should mostly be copy-and-pastable. About MySQL MySQL is an open source database management software that helps users store, organize, and later retrieve data. It has a variety of options to grant specific users nuanced permissions within the tables and databases—this tutorial will give a short overview of a few of the many options. How to Create a New User In  Part 1 of the MySQL Tutorial , we did all of the editing in MySQL as the root user, with full access to all of the databases. However, in the cases where more restrictions may be required, there are ways to create users with custom permissions. Let’s start by making a new user within the MySQL shell: CREATE USER ' newuser '@'localhost' IDENTIFIED BY ' password '; Sadly, at this point newuser ha...

Sed Awk Bash

awk -F ' ' '{ a[$5]++ } END { for (b in a) { print b } }' dm_documents_resource.sql cut uniq column 5 tach boi ‘\ ‘ ‘ ‘ dau cach pfccdlfdtte pcaccplircdt dklpcfrp?qeiq lhpqlipqeodf gpwafopwprti izxndkiqpkii krirrifcapnc dxkdciqcafmd vkfpcadf. [ Code shift 1 ,2 - n word in †´˜çå´¨≥ç®ß®∫˚∆œ∑≥æç©≥π÷´ø˙¨ - 2 shift add position "Sometimes you can have the smallest role in the smallest production and still have a big impact." \ find . -name .svn -exec rm -rf {} \; http://blog.alexgalmeanu.com/ ------------------------- Sort de cut duplicate row (one column same value): $ sort -t, -u -b -k1n text 542 , 8 , 1 , 418 , 1 542 , 9 , 1 , 418 , 1 199 , 7 , 1 , 419 , 10 301 , 34 , 1 , 689070 , 1 It is not sorting based on the first column. Approach 2 $ sort -t, -u -b -k1n, 1n text 199 , 7 , 1 , 419 , 10 301 , 34 , 1 , 689070 , 1 542 , 8 , 1 , 418 , 1 ••••••••••••••••••••••••••• Sort cột cần dùng cho lên đầu...