Cannot start mysqld_safe to reset root password - centos

I installed MySQL and was playing around with the password settings trying to get Wordpress to connect to it. In doing so, I seem to have hashed my root password and now cannot login.
I'm trying to reset the password by running
/etc/init.d/mysqld stop
Then
mysqld_safe --skip-grant-tables
Which outputs
Starting mysql daemon with databases from /var/lib/mysql
But then does nothing. It neither succeeds nor fails. I've not got any databases setup so I'd be happy to remove and reinstall mysql if necessary but I tried that to no avail. How can I get back in?

mysqld_safe is the command to start the mysql engine. It's not supposed to do or show anything after the line saying that it's started mysql. Once you've run mysqld_safe, the next step is to run mysql. Because you started mysqld with --skip-grant-tables you won't need to specify a username or password.
You can then give the command to reset root's password. For instructions on how to set a password, see http://dev.mysql.com/doc/refman/5.0/en/set-password.html .

have you tried "mysqld --skip-grant-tables" instead of mysqld_safe? make sure to kill any mysqld threads that didn't die before starting mysqld --skip-grant-tables. Do a ps -ef and grep for mysql, kill -9 any mysql process, then start it --skip-grants-tables.

Related

How can I run Postgres locally on two accounts

On my MacBook I have two user profiles. One for work and one for personal use. I develop on both and recently I've wanted to start a local Postgres server but I can't seem to do this. When I try to run pg_ctl -D /usr/local/var/postgres I get this error:
pg_ctl: could not open PID file "/usr/local/var/postgres/postmaster.pid": Permission denied
I also can't run it as a super user as it says pg_ctl: cannot be run as root
I think this might be because I installed Postgres on my work user profile and even though I can still access the CLI I can't run the Postgres server as I don't have the right permissions on my personal user profile.
Apologies in advance if this is a really obvious error, I am new to development 😅
If there is a PID file present, either the database is running, or you did not shut it down properly, and it crashed.
Anyway, your idea is doomed. Only the user who owns the database files can start the database server.
Perhaps you can use sudo:
sudo -u dbowner pg_ctl start -D /usr/local/var/postgres
But I guess that you misunderstand the principle of client-server software.
You should have the system start PostgreSQL as a service, running as the database owner. Then it is irrelevant as which operating system user you run the client software (unless you are using peer authentication in PostgreSQL).

Unable to run OTRS daemon, OTRS6 on Cent OS 7

I am facing issue while trying to start ORTS daemon on CentOS linux
FACILITY:
OTRS-otrs.Daemon.pl - Daemon
Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager-07
MESSAGE:
Access denied for user 'otrs'#'localhost' (using password: YES)
When I am trying get the status using command:
./opt/otrs/bin/otrs.Daemon.pl status
getting this message:
Manage the OTRS daemon process.
Daemon running
But when I go to the web page it says that OTRS Daemon is not running.
Any help is appreciated!?
The error comes from the mysql daemon and has nothing to do with Perl. Try this on the command-line on the server running otrs:
mysql --user=otrs --host=localhost --password=XXXXXXX
That will probably fail with the same error. Once you have fixed your mysql configuration so that the command succeeds, otrs should also start.
Omit the option --password and let mysql prompt you for the password, if you are not alone on the machine.
Another reason for the failure could, of course, be that you have misconfigured otrs, and you have to change the mysql user, host, or password.
After searching for solution for two days i finally get it working.
I first change to /opt/otrs/bin/ directory.
To get the daemon working, you have to start the daemon as otrs user.
To do that just change user to otrs : you can use this command. (su otrs) from your terminal, you will be prompted for the password for otrs. Just enter the password and use the (whoami) command to check if you are otrs. If it shows that the current user is otrs issue this command (./otrs.Daemon.pl status) to see the current status of the daemon. if it shows that the daemon not running then issue this command (./otrs.Daemon.pl start).

Postgres 9.0 File System level backup on Debian Jessie

I'm on Debian 8.2.0 and trying to run a postgres server from a folder I received. Version is 9.0.18. Here is the command I issue:
./postgres -D /home/swapps/project/PostgreSQL/9.0/data/
but the cursor keeps blinking in the terminal. I'm not sure what is happening?
Thanks
Sounds like it's started, and log_min_messages is set to a high enough value that you don't see any output.
Using another terminal session connect to the server on the port it's running on. If you don't know that check the port value in the postgresql.conf inside the data directory.
Generally you should use pg_ctl -D blah -w start rather than postgres directly. See the manual.
Or, for long term use, set it up to run on startup via an init script.

How do I reload Postgres.app config without restarting?

With a regular postgres install, I would do this either by sending SIGHUP to the postgres process, or by running pg_ctl reload. With Postgres.app, however, I'm unsure about where to send SIGHUP (to the Postgres.app process, or one of the workers?), and attempting to run pg_ctl reload (after tracking it down to /Applications/Postgres.app/Contents/Versions/9.3/bin yields only complaints about PG_DATA being unset.
So, how do I reload the configuration files for Postgres.app without restarting the whole server? Is this possible?
Simplest way: SELECT pg_reload_conf().

How to run postgres on centos when installed via YUM repo as default daemon user

With a freshly installed version of Postgres 9.2 via yum repository on Centos 6, how do you run postgres as a different user when it is configured to run as 'postgres:postgres' (u:g) out of the box?
In addition to AndrewPK's explanation, I'd like to note that you can also start new PostgreSQL instances as any user by stopping and disabling the system Pg service, then using:
initdb -D /path/to/data/directory
pg_ctl start -D /path/to/data/directory
This won't auto-start the server on boot, though. For that you must integrate into your init system. On CentOS 6 a simple System V-style init script in /etc/init.d/ and a suitable symlink into /etc/rc3.d/ or /etc/rc3.d/ (depending on default runlevel) is sufficient.
If running more than one instance at a time they must be on different ports. Change the port directive in postgresql.conf in the datadir or set it on startup with pg_ctl -o "-p 5433" .... You may also need to override the unix_socket_directories if your user doesn't have write permission to the default socket directory.
pg_ctl
initdb
This is only for a fresh installation (as it pertained to my situation) as it involves blowing away the data dir.
The steps I took to resolve this issue while utilizing the packaged startup scripts for a fresh installation:
Remove the postgres data dir /var/lib/pgsql/9.2/data if you've already gone through the initdb process with the postgres user:group configured as default.
Modify the startup script (/etc/init.d/postgresql-9.2) to replace all instances of postgres:postgres with NEWUSER:NEWGROUP.
Modify the startup script to replace all instances of postgres in any $SU -l postgres lines with the NEWUSER.
run /etc/init.d/postgres initdb to regenerate the cluster using the new username
Make sure any logs created are owned by the new user or remove old logs if error on initdb (the configuration file in my case was found in /var/lib/pgsql/9.2/data/postgresql.conf).
Startup postgres and it should now be running under the new user/group.
I understand this might not be what other people are looking for if they have existing postgres db's and want to restart the server to run as a different user/group combo - this was not my case, and I didn't see an answer posted anywhere for a 'fresh' install utilizing the pre-packaged startup scripts.