Mysql stuck in an expired password loop - mysql-5.7

I can no longer connect to my databases with mysql 5.70.20 on macOS 10.13.1 as I get the following message.
Your password has expired. To log in you must change it using a client that supports expired passwords.
Now, this would seem like an easy fix. But unfortunately I think im stuck in a loop.
Here is what I am trying. mysql -u root this works as expected. After connecting im trying ALTER USER 'script'#'localhost' PASSWORD EXPIRE NEVER; which gives me an ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
After the previous I tried SET GLOBAL default_password_lifetime = 0; which printed Query OK, 0 rows affected (0.00 sec) this als did not fix the problem as nothing was affected.
Then I tried SET PASSWORD = PASSWORD('root'); which printed ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 46. Created with MySQL 50718, now running 50720. Please use mysql_upgrade to fix this error..
So I try to run what it is recommending me mysql_upgrade and this puts me back to where I was mysql_upgrade: Got error: 1862: Your password has expired. To log in you must change it using a client that supports expired passwords. while connecting to the MySQL server Upgrade process encountered error and will not continue.

Solution worked for me on Ubuntu is complete removal of mysql:
sudo rm -rf /var/lib/mysql/mysql
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install mysql-server
This will also remove system tables so you can start from scratch.
Can someone translate this to macOS?

Related

Postgresqll 10: Postgres User /sbin/nologin preventing initdb setup

I'm attempting to install postgresql 10 for the first time and need to run the initdb setup. Unfortunately, this fails and returns an error from the nologin shell.
server# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database ...
failed, see /var/lib/pgsql/10/initdb.log
server# cat /var/lib/pgsql/10/initdb.log
This account is currently not available.
I strace'd the command and verified the su commands are probably what's causing this and it seems the default setting for the postgres user is /sbin/nologin. In various examples I've seen, there is no mention of this being a possible issue. How would this work on any other system by default? I feel that temporarily modifying the login shell would work but I want to understand this issue better more specifically from the application's end.
centos 7.8
selinux mode: permissive
postgresql 10

Accidentally removed super user privilege from user: postgres on postgres 10. How to get it back without re installing?

I accidentally removed the super user privilege from user: postgres. I don't know how to get another super user. I stopped the postgres service and tried logging in with single-user mode:
/usr/pgsql-10/bin/postgres --single -D /var/lib/pgsql/10/data
I get this error:
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
In Linux, how can I start Postgres in single-user mode so I can fix the super user privilege?
Edit: I used this link for reference, but I'm getting the error mentioned above.
Accidently removed postgres default superuser privileges - can I get it back?
I combined solutions from these three links:
Accidently removed postgres default superuser privileges - can I get it back?
Restoring the superuser account on the postgres server
“root” execution of the PostgreSQL server is not permitted
After stopping the postgresql service, I ran this command:
sudo -u postgres /usr/pgsql-10/bin/postgres --single -D /var/lib/pgsql/10/data
/usr/pgsql-10/bin/postgres is the location of my postgres binary
/var/lib/pgsql/10/data is the location of my postgresql conf
This allowed me to access single user mode, where I just typed this command:
ALTER USER postgres SUPERUSER;
So if anyone is experiencing the same scenario as me, please give the posted command a try.
just adding this for postgresql 12 (Ubuntu) and possibly up
sudo -su postgres /usr/lib/postgresql/12/bin/postgres --single -D /etc/postgresql/12/main

Google Compute Engine instance requires password for sudo - what is my password?

I have a new google compute engine instance. I am SSH'ed into the instance using certs. Whenever I try to use sudo it asks for the primary user's password which I do not have. Just recently I setup an instance on centos 7 and did not have this issue.
The instance is running centos 8. Normally, I would ssh to the instance, then execute commands using Sudo. For example, I would like to set the root password.
if I run sudo passwd, sudo su - or even sudo cat /var/log/messages it asks me for the primary user's password. The problem is I do not have that password.
[primaryuser#server4 log]$ **sudo cat messages**
**[sudo] password for primaryuser:**
##########
[primaryuser#server4 log]$ **sudo passwd**
**[sudo] password for primaryuser:**
I expected to run the commands using sudo but do not have the password.
Does anyone have any ideas? I read other posts about similar problems but different from mine.
I had to give up and use ubuntu. Everything acted as expected on ubuntu and I was able to set the password. I believe the problem is limited to centos 8 but I am not certain.

Centos 6.9 - MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk

I'm using Centos 6.9. I have installed Redis using yum:
sudo yum update
sudo yum install redis
No errors were given during the installation.
I can start Redis using redis-cli. It gives me the prompt as expected:
127.0.0.1:6379>
However whenever I issue commands (e.g. PING or SET foo bar) it's giving the following error message:
(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
I've found MISCONF Redis is configured to save RDB snapshots. and gone through it but none of the advice in there works.
The Accepted Answer on the above was to use CONFIG SET to change the directory where Redis was storing data. I tried this in a non-root directory, CONFIG SET dir /home/andy, but it still gives me the same error message.
If I execute BGSAVE it says "Background saving started" but then attempting SET foo bar goes back to giving me the error above.
Other answers have discussed this being a permissions issue. However I don't see how these apply because I've tried starting Redis as both root and my own account (andy) and the same occurs.
I'm not sure if it's the same problem as described on the link or something else.
How can I further diagnose this? I am a PHP developer by trade so this is not my area of expertise, however I am trying to install Redis so I can use it with a PHP application which has it's own interface to Redis.
It seems that the yum installation creates a redis user, and your Redis instance is running by this user. So even if you set dir to /home/andy, this redis user still doesn't have permission to write to andy's home directory.
Use ps aux |grep redis to get the user who's running redis, and config dir to a directory that this user has write permission.
Quick fix for this error is, goto redis-cli and set following
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
Above like just ignore it
I solved the problem by executing following commands:
$ redis-cli
> config set stop-writes-on-bgsave-error no

postgresql createuser -interactive not working in CentOS 7

A fresh installation of CentOS 7 needs a fresh installation of PostgreSQL, with a new user and a new role. I am following the steps described in this tutorial to accomplish this goal. However, the terminal is not providing the interactive menu that the tutorial promises when I type createuser -interactive. Instead, I get the following blank prompt:
[this_centos_user#localhost ~]$ sudo -i -u postgres
[sudo] password for this_centos_user:
-bash-4.2$ createuser –interactive
-bash-4.2$
What specific commands need to be typed in order to get the interactive createuser interface to appear and let me give a username, password, etc.?
The Specific Situation:
1.) First, I installed the postgresql-server package and the "contrib" package with the following command:
sudo yum install postgresql-server postgresql-contrib
2.) Next, I created a new PostgreSQL database cluster:
sudo postgresql-setup initdb
3.) I then set up password authentication editing PostgreSQL's host-based authentication (HBA) configuration by typing sudo vi /var/lib/pgsql/data/pg_hba.conf and changing the following lines to include md5 instead of ident:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
4.) After saving and exiting vi, I started and enabled PostgreSQL with the following:
sudo systemctl start postgresql
sudo systemctl enable postgresql
5.) Next, I logged in to PostgreSQL with the postgres account that we created above, and tried to create the user with the code from the top of the OP above, as follows:
[this_centos_user#localhost ~]$ sudo -i -u postgres
[sudo] password for this_centos_user:
-bash-4.2$ createuser –interactive
-bash-4.2$
So how do I create this user?
Not a direct answer to the question but related:
If you're like me and you've typed createuser --interactive inside of psql, and you're wondering why you've just gone from postgres=# to postgres-#, you've misunderstood the instructions. Exit psql with Ctrl+C and then \q and run createuser --interactive from the shell as the postgres user.
There appears to have been a typo in the tutorial. The correct syntax is:
-bash-4.2$ createuser –-interactive
Note that --interactive in this answer is correct, while -interactive in the OP was wrong.

Resources