Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


StevieT

706 posts

Ultimate Geek
+1 received by user: 34


#310955 3-Dec-2023 11:06
Send private message

Installed LAMP as per https://phoenixnap.com/kb/how-to-install-lamp-in-ubuntu

 

Installed phpMyAdmin as per https://ubuntu.com/server/docs/how-to-install-and-configure-phpmyadmin (plus adding 'Include /etc/phpmyadmin/apache.conf' to /etc/apache2/apache2.conf)

 

Can't log in using the MySQL password set.

 

Get the following:

 

"mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)"

 

 

 

How do I go about resetting this password or otherwise fixing the issue so I can log in?


Create new topic
bigalow
568 posts

Ultimate Geek
+1 received by user: 112




itxtme
2102 posts

Uber Geek
+1 received by user: 557


  #3167812 4-Dec-2023 09:18
Send private message

Isnt the default installation root with no password over localhost?


StevieT

706 posts

Ultimate Geek
+1 received by user: 34


  #3168020 4-Dec-2023 15:24
Send private message

itxtme:

 

Isnt the default installation root with no password over localhost?

 

 

 

 

Tried logging in with just username root and no password, but same message. Yet to look at solutions provided on https://kinsta.com/knowledgebase/mysql-error-1045/

 

 




Firesphere
23 posts

Geek
+1 received by user: 30


  #3168034 4-Dec-2023 16:06
Send private message

In the instructions you linked, nowhere do I see the set-up of the root password.

 

So a few options, all from terminal:

 

     

  1. Try logging in with "sudo mysql"
  2. Scour the logs for the generated password in /var/logs/mysql*
  3. Set-up the password for root with "mysql_secure_installation"
  4. See if there's a password set in `/etc/mysql/debian.cnf`

 

Is this a local or a server installation by the way? Because on a server installation, actively having a root password might not be the best idea

 

If one of them succeeds, you can use that to log in via PMA


StevieT

706 posts

Ultimate Geek
+1 received by user: 34


  #3168062 4-Dec-2023 17:10
Send private message

Firesphere:

 

In the instructions you linked, nowhere do I see the set-up of the root password.

 

So a few options, all from terminal:

 

     

  1. Try logging in with "sudo mysql"
  2. Scour the logs for the generated password in /var/logs/mysql*
  3. Set-up the password for root with "mysql_secure_installation"
  4. See if there's a password set in `/etc/mysql/debian.cnf`

 

Is this a local or a server installation by the way? Because on a server installation, actively having a root password might not be the best idea

 

If one of them succeeds, you can use that to log in via PMA

 

 

I set a password at installation of MySQL. That I am unable to use to log into PHPMyAdmin.


michaelmurfy
meow
13579 posts

Uber Geek
+1 received by user: 10910

Moderator
ID Verified
Trusted
Lifetime subscriber

  #3168076 4-Dec-2023 17:17
Send private message

This is intentional.

 

Normally you won't be able to use root to login to PMA as this is a substantial security risk. It is to stop people doing silly things. You should NEVER use the root user for anything but creating another user.

 

You need to use mysql to create another user (eg - admin) with the permissions you want.

 

sudo mysql -u root -p
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

 

Replace "newuser" and "password" with a username and a secure password.





Michael Murphy | https://murfy.nz
Referral Links: Quic Broadband (use R122101E7CV7Q for free setup)

Are you happy with what you get from Geekzone? Please consider supporting us by subscribing.
Opinions are my own and not the views of my employer.


 
 
 

Shop now at Mighty Ape (affiliate link).
fe31nz
1294 posts

Uber Geek
+1 received by user: 423


  #3168202 5-Dec-2023 00:36
Send private message

michaelmurfy:

 

This is intentional.

 

Normally you won't be able to use root to login to PMA as this is a substantial security risk. It is to stop people doing silly things. You should NEVER use the root user for anything but creating another user.

 

You need to use mysql to create another user (eg - admin) with the permissions you want.

 

sudo mysql -u root -p
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

 

Replace "newuser" and "password" with a username and a secure password.

 

 

There is a difference between using -u root and just running mysql from the root user without any -u option.  If you use -u, then that specific user named "root" must exist in the MySQL database and have the required permissions to create users and set privileges.  To always get full permissions to do anything (including creating users and setting privileges), you should just use "sudo mysql".  You will be prompted for a password by the sudo command, but the mysql command will not ask for one.  The problem you are avoiding here is that sometimes the user "root" in the MySQL database has been changed to have limited capabilities, and may not be able to do the required CREATE or GRANT commands.  Logging into mysql from the root user but not specifying a user name to log in as bypasses this and gives you full control of everything.


Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.