Legit
CopyLeft© | Darmanex Weblog - A journey about virtual world.
2008 - 2019
Powered by Blogger
August 23, 2020

PostgreSQL: password authentication failed for user "postgres"

darmanex | 11:46 PM Be the first to comment!
In our development environment we use postgresql for our database engine. We just create a new database, and our developer requested that they want have new role. The new role will have SELECT access into tables that they requested before.
But something happen when our developer trying to run sql command like below:
# select * from table_name;
ERROR:  could not connect to server "server_master"
DETAIL:  FATAL:  password authentication failed for user "postgres"

In this situation we have to check one by one what's the password of user postgres, and we found the password is different. To check current password of user mappings, you can type \deu+ on psql console.
In this case we will change the password of user mappings. To change the password, assuming you are on the right database, and run this on psql console:
# ALTER USER MAPPING FOR postgres SERVER server_master OPTIONS (SET password 'YOUR_NEW_PASSWORD');

Then check it again the user mappings with \deu+.
Then try it once again.

Cool, we have no error found anymore!
Reference: https://www.postgresql.org/docs/10/sql-alterusermapping.html
August 3, 2020

Linux Kernel 5.8 relased!

darmanex | 2:05 PM Be the first to comment!


Well, as we know that Kernel 5.8 has announced by Linus Torvalds. You guys can directly check his announcement on Linux Kernel Mailing List(LMKM).
And I'm going to upgrade my kernel on Arch Linux. Stay tuned!
February 22, 2019

ERROR MySQL: Can't connect to local MySQL server through socket

darmanex | 12:48 PM Be the first to comment!
Currently I used OpenSUSE as my operating system, so to fix the issue as the title of this post is I'll modified the MySQL config at /etc/my.cnf. Open up the my.cnf config and go find the [client] section and uncomment these 2 lines below:
# port       = 3306
# socket     = /run/mysql/mysql.sock

Don't forget to change mode the my.cnf config file to 600, so just only you can edit it.
# chmod 600 my.cnf

To take effect, please restart mysql service.
# service mysql start

Now you can connect to mysql client by this command
# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.2.15-MariaDB openSUSE package

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Let say you haven't set the root password yet, you could reset/set a new root password with this following step below.
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
-----------SNIP--------------
| user                      |
+---------------------------+
30 rows in set (0.00 sec)

Now set a new root password
MariaDB [mysql]> update user set password=PASSWORD("YOUR_NEW_PASSWORD") where User='root';

Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

And then tells MySQL to put the new changes.
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

After all steps above done, you can now test it to connect to MySQL client with password that you've created.
# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.2.15-MariaDB openSUSE package

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

That's all.
August 24, 2018

Adjusting date and time in openSUSE

darmanex | 5:42 PM Be the first to comment!
When you want to adjust the date and time on Debian/Ubuntu system you can just type this command
$ sudo dpkg-reconfigure tzdata

But, if you use openSUSE, to adjust the date and time just simply run the following command
$ sudo yast2 timezone


Select the region and timezone then press F10/OK, and you're done.
Reference: goo.gl/KLDALY
August 17, 2018

Git: Your branch is based on 'origin/branch', but the upstream is gone.

darmanex | 4:16 PM Be the first to comment!
Since I've added remote branch on my local repository, and when I'm going to checking out a remote branch, I got an error/warning message like the title of this post above. After googling same keywords of the warning message, there was who asked on stackoverflow with the same error message like me.
$ git checkout apps-devel
Checking out files: 100% (208/208), done.
Switched to branch 'apps-devel'
Your branch is based on 'hsp/apps-Dev', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

For your information, the original remote branch is hsp/apps-Dev and I've rename it to apps-devel. I try to pull a remote branch as well, and get another message like below:
$ git pull hsp
Your configuration specifies to merge with the ref 'refs/heads/apps-Dev'
from the remote, but no such ref was fetched.

So this is how to fix it.
First open the git config on your local repo (generally the location at .git/config). Here are my configs for the remote branch:
[branch "apps-devel"]
 remote = hsp
 merge = refs/heads/apps-Dev

and I change it to
[branch "apps-devel"]
 remote = hsp
 merge = refs/heads/apps-devel

Then let's checking it again
$ git pull hsp
Already up-to-date.

$ git status
On branch apps-devel
Your branch is up-to-date with 'hsp/apps-devel'.

nothing to commit, working tree clean

As you can see above, no warning message anymore.

Happy Independence day Indonesia! 🇮🇩
Hiduplah Indonesia Raya
🇮🇩