Access Denied to user root@localhost while using mysql

0 votes

Hi, I am new t linux and this the first time for me working with mysql. So I've been following this tutorial to set up mySQL on my machine. These are the following commands I've used so far:

sudo apt-get update
sudo apt-get install mysql-server-5.5
sudo apt-get install mysql-client-5.5
sudo apt-get install mysql-common
sudo apt-get install glade
sudo apt-get install ntp

After this, when I try and run this:

me@ubuntu:~/Desktop/iPDC-v1.3.1/DBServer-1.1$ mysql -uroot -proot <"Db.sql"

I get this error.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

What am I doing wrong here?

May 13 in Linux Administration by Atul
• 10,240 points
96 views

1 answer to this question.

0 votes

For MySQL versions < 5.7:

the default root password should be nothing so just tap enter after:

mysql -u root

You should obviously change your root password after installation

To set a new password do:

mysqladmin -u root password [newpassword]

This should be enough to set you up for the DB Operations

For versions that came after 5.7:

So when you initialize the server, the data directory of the server is empty:

  • The server is initialized.
  • SSL certificate and key files are generated in the data directory.
  • The validate_password plugin is installed and enabled.
  • The superuser account 'root'@'localhost' is created. The password for the superuser is set and stored in the error log file.

This generates a temporary password. Use this command to show:

shell> sudo grep 'temporary password' /var/log/mysqld.log

Now change the root password, Use:

shell> mysql -uroot -p 

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass5!'; 
answered May 13 by DareDev
• 6,810 points

Related Questions In Linux Administration

0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31 in Linux Administration by Omkar
• 67,380 points
31 views
0 votes
1 answer

Not able to access /etc/sudoers.d/python file

I think your system is not allowing ...READ MORE

answered Feb 6 in Linux Administration by Lohit
109 views
0 votes
1 answer

How to remove brackets using sed?

Try this: sed 's/[()]//g' <<< Hi(hello).How are you? READ MORE

answered Feb 12 in Linux Administration by Omkar
• 67,380 points
38 views
0 votes
1 answer

how to loop through the content of a file using bash

One of the ways to do it ...READ MORE

answered Feb 15 in Linux Administration by ajs3033
• 7,280 points
73 views
0 votes
1 answer

Want a command to be executed in Salt only if a directory is empty

You should consider using this inside your ...READ MORE

answered Jun 12, 2018 in DevOps Tools by Damon Salvatore
• 5,510 points
38 views
0 votes
1 answer

Creating A New MySQL User In Amazon RDS Environment

AWS RDS security groups documentation (a common ...READ MORE

answered Jul 18, 2018 in AWS by Priyaj
• 56,520 points
141 views
0 votes
1 answer

Using conditional to execute a command in salt

You can use unless inside your state ...READ MORE

answered Jul 23, 2018 in Other DevOps Questions by DareDev
• 6,810 points
74 views
0 votes
1 answer

How to perform proxy http request using curl?

One of the ways is: export http_proxy=http://your.proxy.server:port/ Then you ...READ MORE

answered Mar 26 in Linux Administration by DareDev
• 6,810 points
127 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 20 in Linux Administration by DareDev
• 6,810 points
30 views