Score:1

Mysql database root access denied

kr flag

I cannot access my sql database on my server 22.04 LTS as root from localhost with and without password after just installing mysql-server-8.0 via apt I have tried to alter the password via the command.

sudo mysqld --init-file=/home/me/paasReset

with in the file:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

but I still cannot access mysql via root@localhost. I have also tried to alter the password by updating the user table directly

Do note I am logged in via SSH on the server.

in flag
Only the super user can connect to MySQL as the `root` account, and there should be no need to ever specify a password for the `root` user in MySQL as anyone with admin access to the server has admin access to everything on the machine. So, with that said, this is how you connect as the database administrator: `sudo mysql`
reventcake295 avatar
kr flag
I have also tried that after just installing it but that was met with access denied thus causing me to try to reset my password
in flag
If this is the case, then it sounds like you're not using the default version of MySQL that comes with Ubuntu 22.04 (or have tried re-installing without first eliminating the orphaned files that are left behind with an uninstall). This is a standard tool that gets deployed across the fleet of machines at work, and they are all accessed the same way.
Score:-1
cn flag

These are not the same user:

sudo mysqld --init-file=/home/me/paasReset

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

One is your admin account the other is root.

Please do setup a root account in mysql but only for emergencies; when you lock yourself out.

The compatible commands are:

ALTER USER '{adminuser}'@'localhost' IDENTIFIED BY 'MyNewPass';
sudo mysqld --init-file=/home/me/paasReset

and

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
sudo -i
mysql

to connect to command line mysql and do maintanence.

I have also tried that after just installing it but that was met with access denied thus causing me to try to reset my password

You do that using

sudo -i
mysql
ALTER USER '{adminuser}'@'localhost' IDENTIFIED BY '{newpassword}';
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.