How to change the root password after memsql install? - singlestore

I've installed MemSQL community edition (single host cluster) and all is working well. I need to allow remote access to the database, but MemSQL installs the user root without a password. If I open up the 3306 port on the firewall, memSQL happily allows anyone to log in as root without a password.
I've tried to change the root user password via
mysqladmin -u root -h 127.0.0.1 password abc123
but I get the error of
mysqladmin: unable to change password; error: 'Unknown system variable 'password''
I also tried to change after connecting as root. all of these fail:
mysql> SET PASSWORD = 'abc123';
ERROR 1193 (HY000): Unknown system variable 'PASSWORD'
mysql> SET PASSWORD = PASSWORD('abc123');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('abc123')' at line 1
mysql> SET PASSWORD = OLD_PASSWORD('abc123');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('abc123')' at line 1
So I'm stuck. The docs for MemSQL are pretty lightweight on this issue as well, and they don't seem to have a community page where I can ask about this. I figure it's something really simple that I'm trying to do, not sure why it's so difficult, and for that matter, I'm not sure why MemSQL defaults to no security at all.
Any ideas?

In the June 2015 release of MemSQL Ops, you can now change the root password with one command using the memsql-update-root-password command. See these links for more information:
http://docs.memsql.com/4.0/ops/cli/MEMSQL-UPDATE-ROOT-PASSWORD/
http://docs.memsql.com/4.0/admin/security/#adding-or-updating-the-root-password
I hope this helps!

In MemSQL to change a password of a user you should use the GRANT command:
grant all on *.* to 'root'#'localhost' identified by 'password' with grant option;
grant all on *.* to 'root'#'%' identified by 'password' with grant option;
Refer to the manual of the GRANT command and to a very detailed manual of configuring the cluster security:
http://docs.memsql.com/latest/ref/GRANT/
http://docs.memsql.com/latest/admin/security/#configuring-password-security

Try
mysql --user=root --password=abc123 --host=127.0.0.1
or
mysql -u root -p abc123 -h 127.0.0.1
Reference: Mysql man page.
You can change the root password with:
GRANT ALL ON *.* TO "root"#"%" IDENTIFIED BY 'password' WITH GRANT OPTION

I observed one strange thing while changing password for root user in mysql as below.
mysqladmin -u root password 'mypassword'
Got error as
mysqladmin: unknown variable 'database=mydatabase'
The reason for this is mydatabase variable has been set in the /etc/my.cnf file. I commented out that line, then everything works fine.
I though of sharing this in this thread.

Related

postgreSQL password authentication failed for user

I'm taking a full WebDev course and got really hard stuck on this matter. I've installed postgreSQL 14.2 for Windows 10 and the instructor said that pgAdmin4 would come together, which it didn't, so then i installed pgAdmin4 individually. I've setted everything up and created a testing database, which is called 'test', and also a table, everything through Windows Powershell command lines, following the course instructions. Now, when i try to access this database through PowerShell command psql 'test' and type the requested password for the OS user i get a Fatal Error, which follows:
PS C:\Users\theu_\desktop> psql 'test'
Password for user theu_:
psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "theu_"
I've tried my OS username password and the postgreSQL password, none of them works. What am i missing or did wrong?
Thanks in advance
Try accessing postgres by using psql -U postgres in cmd, postgres being the name of the superuser for postgres itself (if you did a basic install) - while windows is probably trying to access postgres with your windows name.
You should also be able to use SQL Shell to access your database without denoting a user.

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

Syntax Error when trying to reset Root password in MariaDB shell

I have installed MariaDB-server(10.1.34) freshly on Linux Ubuntu 18.04
I have started a SQL shell with:
sudo -i
mysql -uroot -p -h localhost
The shell opens.
I want to change my password to be compatible with Node.js typeorm and mysql driver(as I always get this error) with the following:
ALTER USER root#localhost IDENTIFIED BY '12345';
And it always says I have an error in my syntax but I checked online and it's even on MariaDBs ALTER USER site. What is going wrong here?
I tried:
ALTER USER root#localhost IDENTIFIED BY '12345';
ALTER USER 'root'#'localhost' IDENTIFIED BY '12345';
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '12345';
ALTER USER 'root'#'localhost' IDENTIFIED WITH 'mysql_native_password' BY '12345';
ALTER USER root#localhost IDENTIFIED WITH mysql_native_password BY '12345';
But nothing works. I always get a syntax error, but I don't know where I made a mistake. Can someone point out my mistake?
From https://mariadb.com/kb/en/library/alter-user/ :
The ALTER USER statement was introduced in MariaDB 10.2.0.
See also the older SET PASSWORD: https://mariadb.com/kb/en/library/set-password/

MongoDB auth=true clusterAdmin still has lack of priveleges

I need a little help with mongo.
I installed 2.4.9 version from accroding to this instructions:
For ubuntu - http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
For Debian - http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/
I followed manuals and documentation. Everything worked fine but when I change mongo settings to "auth=true" permissions go crazy.
Here is my user:
{
"_id" : ObjectId("5305dd8729ae7b95a4bde944"),
"user" : "root",
"pwd" : "063bbfd478f7b78df6c93b6202af9145",
"roles" : ["clusterAdmin", "userAdminAnyDatabase",
"readWriteAnyDatabase", "dbAdminAnyDatabase" ] }
I used rockmongo. And when I open my mongodb it says that I don't have enough permissions to run command db.getCollectionNames()
It says: Execute failed:unauthorized
And the same thing for creating users, managing databases.
I can't imagine what more permissions should I provide to user.
As it is said in manual this user is the first one I created. I gave him all highest admin privileges.
After changing auth parameter to auth=true
I also can't login in command line.
$ mongo -uroot -p <my password> --host 127.0.0.1
MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:27017/test
Thu Feb 20 11:56:17.510 Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails" } at src/mongo/shell/db.js:228
exception: login failed
By the way I tried password with and without braces. With long option and short one. This way -p<my password> and this way -p <my password>
But application (use simple db users) works fine.
I created database and two users (before making auth=true) and they seems fine for applications that use them.
I couldn't google any information. In most cases adding clusterAdmin or other permissions solves the problem for them.
OS: Ubuntu 12.04 and Debian 7 (In both same behavior)
MongoDb: 2.4.9
What is my mistake?
Did you create the user on the admin database?
clusterAdmin and the *AnyDatabase permissions apply only on the admin database.
When you authenticate, you'll need to authenticate against the admin database and then access other databases according to user's permissions.
mongo --authenticationDatabase admin -u root -p <my password> --host 127.0.0.1

Installing Postgresql and PgAdmin3 on Linux

I use Postgesql and PgAdmin on Windows without any problems but am struggling to get it working on Linux (I'm a Linux N00b). I have installed the 64bit version on my Fedora box following these instructions (except substituting version 9.3 for 9.2). Everything works well until I get to launching pgsql with:
sudo -u postgres psql template1
Here I get an error "Permission denied" as is attempts to change to my home directory.
I can change the password for 'postgres' as per the instructions and I presume this is just so I can use 'md5' rather than 'trust' in pg_hba.conf (if not, then I don't understand why I need this step).
When I fire up PgAdmin3, initially I have no connections. Attempting to connect to the server gives me an authentication error for user 'postgres'. I have tried resetting pg_hba.conf to 'trust' but that doesn't work either.
I would appreciate an explanation of the 'postgres' user in Linux as it appears to be a separate actual user on the Linux system (unlike Windows where it is just a 'disembodied' user relevant only to Postgress). Secondly, help in getting PgAdmin speaking to Postgresql would be gratefully received.
psql -U postgres template1
It will prompt for password if you set md5 in pg_hba.conf
After much digging about I found that most of the documentation is incomplete. I needed a combination of connecting via Cefull Lo's solution (+1) and NOT (as in most of the documentation):
sudo -U postgres psql
Then to change the password I need a more explicit SQL command as follows
template1=# ALTER USER postgres with encrypted password ‘yourpassword’;
I presume that I need to explicitly state 'with encrypted password' because I am using md5, though again, 90% of the documentation fails to point this out and advises a basic change of password together with md5. Maybe this is specific to Fedora, who knows, but now I can connect via PgAdmin3.

Resources