Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

mysql connect ubuntu

Posted on 2009-12-23
24
Medium Priority
?
798 Views
Last Modified: 2012-05-08
Hello
New to ubuntu and just downloaded mysql using sudo apt-get install mysql-server
--seemed to be ok - then type in mysql and got the following...
ERROR 1045 (28000): Access denied for user 'philipsivyer'@'localhost' (using password: NO)
how do I get round this please
0
Comment
Question by:philsivyer
  • 11
  • 7
  • 6
24 Comments
 
LVL 19

Expert Comment

by:Barthax
ID: 26111290
A default installation will have only one SQL user: root.  Use:

mysql -u root
0
 
LVL 9

Expert Comment

by:jeff_01
ID: 26111300
You need to connect using the root account until you have set up more mysql users

mysql -u root

I believe the default password is blank.
0
 

Author Comment

by:philsivyer
ID: 26111317
Hello
TRied that - Now get this
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 19

Expert Comment

by:Barthax
ID: 26111352
OK, so there must be a password on the SQL root account - presumably you were requested to enter one during the install?

mysql -u root -p

Using the above will give a password-prompt & should then allow you in.
0
 
LVL 9

Expert Comment

by:jeff_01
ID: 26111371
Try

mysql -u root -p

Then when it prompts for the password just press enter and see how that goes.

When you installed did it not run a config script which asked for a root password? If it did try

mysql -u root -p password

0
 

Author Comment

by:philsivyer
ID: 26111421
Hello
It did not prompt me for a password on the install and the strange thing is that when I open the Terminal and type mysql -u root -p it then goes to new line which is .. Enter password: - which is fine but for some reason I am unable to type anything in - weird! when I hit return for a new prompt then it's ok and I can type in anything I want.
0
 
LVL 19

Expert Comment

by:Barthax
ID: 26111437
You will not receive any echo when typing the password: whatever you type during the password prompt will not be displayed. Have you tried simply pressing return?
0
 

Author Comment

by:philsivyer
ID: 26111453
Yes
I get ..
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
0
 
LVL 19

Expert Comment

by:Barthax
ID: 26111476
That confirms the SQL has been set up with a password.  I've never looked into password-cracking on MySQL, so I'm not about to suggest anything in that direction.  Has the machine ever had MySQL installed before? If so, it is potential that an old system DB is inplace & the new install just picked up where that left off.  If this is a truly brand new install, I would suggest uninstalling (sudo apt-get remove mysql-server) and then re-install.
0
 

Author Comment

by:philsivyer
ID: 26111484
It has had a previous version - I will remove and re-install
0
 

Author Comment

by:philsivyer
ID: 26111520
Does this make any more sense .. still not working ..
sudo apt-get remove mysql-server
[sudo] password for philipsivyer:
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-2.6.31-14 libnet-daemon-perl libhtml-template-perl libdbi-perl
  libdbd-mysql-perl mysql-server-5.1 mysql-client-5.1 libplrpc-perl
  mysql-server-core-5.1 linux-headers-2.6.31-14-generic
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED
  mysql-server
0 upgraded, 0 newly installed, 1 to remove and 66 not upgraded.
After this operation, 102kB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 166965 files and directories currently installed.)
Removing mysql-server ...
philipsivyer@ubuntu:~$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree        
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-2.6.31-14 linux-headers-2.6.31-14-generic
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed
  mysql-server
0 upgraded, 1 newly installed, 0 to remove and 66 not upgraded.
Need to get 0B/63.9kB of archives.
After this operation, 102kB of additional disk space will be used.
Selecting previously deselected package mysql-server.
(Reading database ... 166962 files and directories currently installed.)
Unpacking mysql-server (from .../mysql-server_5.1.37-1ubuntu5_all.deb) ...
Setting up mysql-server (5.1.37-1ubuntu5) ...
philipsivyer@ubuntu:~$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
philipsivyer@ubuntu:~$ mysql
ERROR 1045 (28000): Access denied for user 'philipsivyer'@'localhost' (using password: NO)
philipsivyer@ubuntu:~$ mysqladmin -u root password 'blktbhl7'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
philipsivyer@ubuntu:~$
0
 
LVL 19

Expert Comment

by:Barthax
ID: 26111550
You mentioned that this was not the first time MySQL had been installed.  The new installation must be using the old databases - those old databases must be set up so that the MySQL root user has a password.  Have you inherited this installation & therefore unaware of the password or is there a previous admin (or yourself) which would have access to that password?
0
 

Author Comment

by:philsivyer
ID: 26111611
I have a dual system using Windows and Ubuntu - mysql is already installed with Windows - would that have any impact?
0
 
LVL 9

Expert Comment

by:jeff_01
ID: 26111633
Follow the instructions in the link below to reset the mysql root password. You need to be logged in as root on the system.

"su"

http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html

0
 
LVL 19

Expert Comment

by:Barthax
ID: 26111634
I doubt it, however, the simplest method to finding out would be to see if the root password for the Windows' MySQL installation works on this new install.

If that simple test fails, try the following:

mysqladmin -u root password <mynewpassword>

(Obviously replace <mynewpassword> with what you want to use.)  If that requires you to enter a password (access denied), then I'm very close to being stumped.
0
 

Author Comment

by:philsivyer
ID: 26111656
Hello
Went back to Windows opened myssql with no problem and password was accepted - now back in ubuntu and still have same problems - tried resetting pasword but still get ..
connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

I guess if all else fails I go back to Windows
0
 
LVL 9

Accepted Solution

by:
jeff_01 earned 1000 total points
ID: 26111721
One more thing, perhaps you need to set a password before you will be able to gain access.

Try,

mysqladmin -u root password 'new-password'

To set a new password
0
 
LVL 9

Expert Comment

by:jeff_01
ID: 26111724
Sorry, I didnt read Barthax's exact same post.

Nevermind me  :(
0
 
LVL 9

Expert Comment

by:jeff_01
ID: 26111730
Did you try the procedure in the link I posted above?

0
 

Author Comment

by:philsivyer
ID: 26111872
I'm trying the link and got to the part where it says ..................

You can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the path name of the .pid file in the following command:
shell> kill `cat /mysql-data-directory/host_name.pid`

my path to file mysql.pid is ... /var/run/mysqld so what would now be the command now
shell> kill 'cat/????????
0
 

Author Comment

by:philsivyer
ID: 26111919
OK
Ignore previous comment - now on next part of the process
Phil
0
 

Author Comment

by:philsivyer
ID: 26112015
Hello
Tried the kill process but permission denied - I think I will uninstall and use windows where mysql works
0
 

Author Comment

by:philsivyer
ID: 26112053
I'm bowing out for a few hrs - gone to take a frustration pill
0
 
LVL 19

Assisted Solution

by:Barthax
Barthax earned 1000 total points
ID: 26112490
Just skimmed of the Unix instructions in that MySQL instructions & noticed this bit:

> 1. Log on to your system as the Unix mysql user that the mysqld server runs as.

Try running through the instructions as (Linux) root instead.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question