LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-05-2011, 07:21 AM   #1
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Rep: Reputation: 30
cannot connect to mysql


I cannot connect to mysql on my server.
It is running but I cannot remember whether it has a password or not.
I get this:
[root myscripts]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root myscripts]#

I have tried running mysql -u root -h localhost -p and entering a blank password but no luck.
ANy ideas what to do?
 
Old 04-05-2011, 07:36 AM   #2
nidhinmd
Member
 
Registered: Aug 2007
Location: Cochin, Kerala, India
Posts: 32

Rep: Reputation: 3
Hi
Check this http://www.cyberciti.biz/tips/recove...-password.html
 
Old 04-05-2011, 09:00 AM   #3
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Original Poster
Rep: Reputation: 30
I followed all of that except I had to use mysqld instead of mysql in all the commands.
It update the rows with the new password but it still won't connect:

Code:
[root myscripts]# /etc/init.d/mysqld stop
Stopping MySQL:                                            [  OK  ]
[root myscripts]# mysqld_safe --skip-grant-tables &
[1] 17981
[root myscripts]# Starting mysqld daemon with databases from /var/lib/mysql

[root myscripts]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password='mypswd' where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3  Changed: 0  Warnings: 0

mysql> update user set password='mypswdtest' where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> update user set password='mypswd' where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root myscripts]# /etc/init.d/mysqld stop
STOPPING server from pid file /var/run/mysqld/mysqld.pid
110405 13:57:35  mysqld ended

Stopping MySQL:                                            [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables
[root myscripts]# /etc/init.d/mysqld start
Starting MySQL:                                            [  OK  ]
[root myscripts]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root myscripts]# mysql -u root -p mypswd
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root myscripts]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root myscripts]#
I also tried this version instead for mysqld: http://www.cyberciti.biz/faq/mysql-r...root-password/
and get this error:
[root myscripts]# Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
110405 14:05:35 mysqld ended

Last edited by qwertyjjj; 04-05-2011 at 09:06 AM.
 
Old 04-05-2011, 09:08 AM   #4
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Original Poster
Rep: Reputation: 30
Forget that:
this line I realised had to be
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';

update user set password=PASSWORD("mypswd") where User='root';
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL serve vinnyband Linux - Software 3 10-30-2008 03:53 PM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 02:52 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 04:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 09:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration