Tuesday, March 6, 2018

AWS RDS - Create mysql user with superuser Privileges

Login as super user on command prompt.

Run following query to create user.
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
Just change username and password in above query and execute as root user. A new user will be created.

Now give super user privileges to new user.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'username'@'%' WITH GRANT OPTION;
Just change username in above query. Your new created user will be a super user now.

AWS RDS - Give Superuser Privileges to Regular mysql User

Login as super user on command prompt.

Run following query to give superuser privileges to normal user.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'username'@'%' WITH GRANT OPTION;
Just change username in above query and execute as root user. Your regular user will be a super user now.

Wordpress Permissions - Upload plugin using wp-admin

Upload plugin using wp-admin without ftp.

If you are not able to install plugin using wp-admin because of forbidden error or a permission issue, you simply change the permission of whole wordpress directory to fix it. That is very dangerous and a common security loophole.

Here is the minimum permission for your plugin directory which is enough to instal plugin using wp-admin.

Give 777 to wp-content/plugins and wp-content/upgrade Non-Recursively. It will allow admin to install plugin using wp-admin.


postgresql error : ERROR: database is being accessed by other users

ERROR:  database "X" is being accessed by other users
DETAIL:  There is 1 other session using the database


Solution :
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'database-name';
You need to replace only database name in above query.

Now you can drop the database or perform other activity what you were trying to perform.

composer update - exceeded the timeout of 300 seconds

Failed to download from source: The process  exceeded the timeout of 300 seconds.

Solution :
Increase the timeout limit globally for composer
composer --global config process-timeout 6000
Now run
composer update
You should not get timeout issue.

gitlab forbidden issue

This feature has been added by default in recent update of gitlab.
When there are number of failed login attempts while cloning or pushing files into gitlab repository, gitlab blocks UI as well as pull and push for the IP. Technically, it bans the IP.

Solution :
Disable this feature.

sudo nano /etc/gitlab/gitlab.rb
Uncomment these lines.
gitlab_rails['rack_attack_git_basic_auth'] = {
'enabled' => false,
}
Reconfigure gitlab.
sudo gitlab-ctl reconfigure
Now it will not block that ip after number of failed login attempts.

ubuntu 16.04 - wkhtmltopdf error - QSslSocket: cannot resolve CRYPTO_num_locks

wkhtmltopdf error on ubuntu 16.04 :
Loading pages (1/6)
QSslSocket: cannot resolve CRYPTO_num_locks                  ] 10%
QSslSocket: cannot resolve CRYPTO_set_id_callback
QSslSocket: cannot resolve CRYPTO_set_locking_callback
QSslSocket: cannot resolve sk_free
QSslSocket: cannot resolve sk_num

Solution :

sudo apt-get install libssl-dev=1.0.2g-1ubuntu4.10 openssl=1.0.2g-1ubuntu4

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

Ruby Error while installing charlock_holmes 

Error :
Fetching charlock_holmes 0.7.5
Installing charlock_holmes 0.7.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.



Solution : 1

If you are using debian or ubuntu
sudo apt-get install libicu-dev

If you are using Centos or fedora
sudo yum install libicu-devel

Solution : 2
Try to install other version of charlock_holmes
gem pristine charlock_holmes --version 0.6.9.4
or
gem install charlock_holmes -v '0.6.9'