ERROR 1045 (28000): Access denied for user 'users'#'host' - shell

Mysql is making me crazy....
I know that this question has been asked 1000 times but nothing works for me... I can't connect to mysql ! This arrived after I update ubuntu 13.1
$> mysql
ERROR 1045 (28000): Access denied for user 'jeremy'#'localhost' (using password: NO)
$> mysql -u root -p****
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
$> cd my_work ; rails c
Access denied for user 'working'#'localhost' (using password: YES) (Mysql2::Error)
I have tried a thousand of command lines, the only thing that not show me a permission denied is to run mysqld with the --skip-grant-tables option but once started, It is like I have no users in my db, even root user ! More, I could not create or update users because of the --skip-grant-tables
$> sudo su
$> service mysql stop
$> mysqld --skip-grant-tables --skip-networking &
$> UPDATE user SET password=PASSWORD('********') WHERE user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
$> SELECT host, user, password FROM user;
localhost | debian-sys-maint | *5480DE723DE487F407399B5208AA09588E67850E
Are all my users deleted ? Is my root user deleted ? How to fix that ?!
for #user2503775, my database.yml :
development:
encoding: utf8
adapter: mysql2
reconnect: true
database: working
username: working
password: working
socket: /var/run/mysqld/mysqld.sock

Related

Why I can't connect to mysql docker locally with Laravel?

I follow the official documentation for Windows at https://laravel.com/docs/9.x#getting-started-on-windows.
curl -s https://laravel.build/example-app | bash
cd example-app
./vendor/bin/sail up
Containers are fine and running. I open mysql command line and run:
mysql -h localhost -u root -p
I enter no password (just enter) and I get:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)

Access deined while configuring mysql ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)

I am following this post on How to Install MySQL on Ubuntu 20.04 LTS?
Updated package index sudo apt update
Installed MySQL server sudo apt install mysql-server
Configuring MySQL sudo mysql_secure_installation, entered password
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Connect to MySQL server
When I use this sudo mysql, I get the following error shown below
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
When I use this sudo mysql -u root, I get the following error shown below
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
When I use this mysql, I get the following error shown below
ERROR 1045 (28000): Access denied for user 'username'#'localhost' (using password: NO)
When I use this sudo mysql -u root -p, I get the following error shown below
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I tried resetting the password following official Mysql B.3.3.2 How to Reset the Root Password and How to Change MySQL Root Password in Ubuntu 20.04
Stopped server sudo systemctl stop mysql.service
Checked the status sudo systemctl status mysql.service
Skipped the grant tables & networking sudo systemctl set-environment MYSQLD_OPTS="--skip-networking --skip-grant-tables"
Started server sudo systemctl start mysql.service
Checked the status sudo systemctl status mysql.service
Sign in to MySQL shell sudo mysql -u root, I get the same error
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
What is the mistake? How do I correct it?
When you are here: mysql_secure_installation try to insert the password:"rootroot"
In mac is assigned by default.

#1045 - Access denied

MySQL said:
1045 - Access denied for user 'root'#'localhost' (using password: YES)
mysqli_real_connect(): (28000/1045): Access denied for user 'root'#'localhost' (using password: YES)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL

createuser: could not connect to database postgres:

I am trying to create a user in PostgreSQL in Mac with the following command
createuser -P project_user
It then prompts
Enter password for new role:
Enter it again:
Password:
I enter thrice the new password for project_user but authentication fails with the below error.
createuser: could not connect to database postgres: FATAL: password authentication failed for user <my_mac_user_name>.
I was able to enter psql terminal with following command and password as 'postgres'
sudo -u postgres psql
\du displays the user project_user.
But same error appears when trying to create database with below command
createdb -O project_user DB_NAME

How to run openERP as a user but using a different database username?

I run my OpenERP through this command:
ghelo#pc$ /usr/bin/python2 openerp-server -c my_config.conf
I have these as database credentials:
username: odoo
password: some_password
My my_config.conf file has these relative lines:
db_host = False
db_maxconn = 64
db_name = False
db_password = some_password
db_port = False
db_template = template1
db_user = odoo
dbfilter = .*
My pg_hba.conf file has these append, restarting the sevice postgresql at every edit:
host all ghelo all md5
local all odoo trust
However running the server raises this exemption:
FATAL: Peer authentication failed for user "odoo"
My question is, how can i run the OpenERP server?
Other Facts:
odoo has a bash account via: $ sudo useradd odoo
psql: # CREATE USER odoo WITH SUPERUSER LOGIN CREATEDB INHERIT PASSWORD 'some_password';
psql: # CREATE DATABASE odoo OWNER odoo;
Unfortunately I have these limitations:
I cannot run sudo -u odoo COMMAND or any bash command to use a different bash user.
I can only run using /usr/bin/python2.
Bash username and database username cannot be the same.
I feel silly, I have been rule of precedence-ed. The ordering of lines in pg_hba.conf matter. I solved the issue by:
Placing this line:
local all odoo trust
Just before:
# "local" is for Unix domain socket connections only
local all all peer
and then restart your postgresql service from root user using this command:
systemctl restart postgresql.service

Resources