1045-Access denied for user 'root'#'localhost' (using password: NO) (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE') - laravel-7

I am working with laravel 7 and after clone my existing repo which was created via windows operating system and right now i am using macOS.
After cloning I copy .env.example and converted into .env file and then run the below commands,
composer install
npm install && npm run dev
php artisan key:generate
All of the above commands run perfectly and then i run the 4 number commands to seed the database.
php artisan migrate:fresh --seed
After run the php artisan migrate:fresh --seed, I have faced an error [1045] Access denied for user 'root'#'localhost' (using password: NO) (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')
Then I checked the php version and it showed php version: 8 and that's why I downgrade the php version from version 8 to 7.4 and right now the requires version are given below,
PHP Version: 7.4.30
Composer Version: 2.4.1
then I clone again and run the same commands 1,2,3 and 4 but iot's sorrow that I have faced same error again. Please check the attached file and check the error and help me to solve the error.

That indicates a problem with your database connection. Your Laravel application is not able to connect to the MySQL database. Check that mysql is running and that you have the correct database name, port, user, and password for your mysql client, or try connecting to mysql outside of the application.
Once you have completed the preceding steps and are able to connect to MySQL from outside of the application, you can run:
php artisan optimize:clear
php artisan cache:clear
php artisan config:cache
php artisan migrate:fresh --seed

There maybe 2 problems with your database connection.
Try to write correct database username and password at your .env file, in case you have created manually,
OR
If you are working on existing database, then try to create new user for your my sql database,
Open your mysql database go to privileges, add new user for your database and set password, then rewrite the username and password at .env file.

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

Errors setting up Ruby development environment: nodejs not found, could not connect to server

I'm a new developer-in-training attempting to set up my Ruby development environment on a Windows machine using Ubuntu. I'm following the instructions here:
https://gorails.com/setup/windows/10
I've made it to the last few steps of the process, which is where I'm started to get errors:
# Navigate to the C: drive on Windows. Do this every time you open the Linux console.
cd /mnt/c
# Create a code directory at C:\code for your Rails apps to live (You only need to do this once)
mkdir -p code
#### If you want to use Postgres
# Note that this will expect a postgres user with the same username
# as your app, you may need to edit config/database.yml to match the
# user you created earlier
rails new myapp -d postgresql
#### or if you want to use SQLite (not recommended)
# rails new myapp
#### Or if you want to use MySQL
# rails new myapp -d mysql
# Then, move into the application directory
cd myapp
# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified
# Create the database
rake db:create
rails server
On the step to set up Postgres:
rails new myapp -d postgresql
I receive this error about setting up nodejs:
/home/event/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /home/event/.rbenv/versions/2.6.5 in PATH, mode 040777
sh: 1: node: not found
sh: 1: nodejs: not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
Even after I go to the URL provided and install NodeJS, that error still shows up when I attempt to repeat the process. Is this just a matter of it not existing in the correct path and I need to relocate it?
Also, I've attempted to proceed with the other steps despite that error. When I enter this command, the second last one in the article referenced above:
rake db:create
I receive this error:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Couldn't create 'myapp_development' database. Please check your configuration.
rake aborted!
ActiveRecord::NoDatabaseError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Tasks: TOP => db:create
(See full trace by running task with --trace)
I've searched around about this with little success, and attempted to decipher what the error messages mean; but at my current level of knowledge it just seems beyond me. Appreciate any insight anyone has to share on this!

Set password to meteor's mongo database

I have deployed a meteor project in a stage server and 2 days ago I found out mongodb had no password. I was able to connect to mongodb with robomongo by only providing the IP(no username, no password).
I want to set a password to protect it. I have been following this documentation but I get "mongo/mongod not a command" when writing these commands in application's root directory or after "meteor mongo" command.
What am I missing here, how can I protect mongodb with a password?
Thanks
I don't think you can, when you are running Meteors built-in MongoDB server.
The reason for this is that if you put a password on that database, Meteor will not be able to connect to it.
And to specify a password in the MongoDB connection you need to set the MONGO_URL environment variable.
And when you do that Meteor will think you are running an external MongoDB installation and it will not even start the built-in MongoDB server.
So it's kind of catch-22.
To set a password you need to have a separate MongoDB installed on your server, set a password on that one, and then tell Meteor to use it using a MONGO_URL environment variable in the format:
mongodb://username:password#127.0.0.1:27017/meteor
See https://docs.meteor.com/api/collections.html#mongo_url
Writing this as an answer because it is impossible to format text in a comment, it makes it very hard to read.
I assume you are running on an Amazon linux server, then.
If you really read the install instructions you linked to, you will see that it is not a ton of commands at all.
Install 1: Create the /etc/yum.repos.d/mongodb-org-3.2.repo file with the content given.
Install 2: sudo yum install -y mongodb-org
Run: sudo service mongod start
Done! MongoDB is now running and listening to port 27017.
You can now add a password, and set MONGO_URL as above.

Login as postgres user in mac

I have a new installation of postgres in my mac using brew install.
I am trying to login to postgres user using sudo -su postgres
I get the error postgres does not know where to find the server configuration file. You must specify the --config-file or -D invocation option or set the PGDATA environment variable in mac
Can anyone please assist to point out where the error is originating from?
I want to log in as postgres and then create a new role,then create a database with owner 'newrole'.
Regards

Resources