Create Database and User in MySQL or MariaDB in shell
I write this because just a note or cheatsheet for me to copy and paste from here to make my life easier. Every time when migrate website from one server to one server, I need to recreate the user and database before insert back to the new host.
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Gem files will remain installed in /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2 for inspection. Results logged to /var/www/discourse/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/mysql2-0.5.2/gem_make.out An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue. Make sure that gem install mysql2 -v ‘0.5.2’ –source ‘https://rubygems.org/’ succeeds before bundling. In Gemfile: mysql2 I found the best way to solve the problem. I think that you may missing …
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue. Read More »
Optimize MySQL order by RAND()
It is not recommended to use ORDER BY RAND() only, it will slow for query large database like over 50,000 rows. The easiest way to optimize existing code, just add RAND()< (SELECT ((1/COUNT(*))*10) FROM Table_name) after the WHERE before the ORDER, this sub query will speed up the select random from the table. Using this …