LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-17-2004, 03:23 PM   #1
ronkymac
Member
 
Registered: Nov 2004
Location: Scotland
Distribution: Debian
Posts: 72

Rep: Reputation: 15
Unhappy AAARGH! What have I done to MySQL??!


Hello all,

Decided, after a long time, to venture into the depths of MySQL... not such a bright idea, it seems.

Today, I installed MySQL 4.x on my 9.0 SuSE server, and typing 'mysqladmin version' came back with the expected result, so MySQL was obviously alive.

After that, however, I came across this guide on the net which told me to enter a password for the mysql database. Inevitably, it was different from my root and unprivileged user passwords. In fact it was so different that I managed to forget it... uh oh.

So I used this guide to try to reset the password, with no luck whatsoever. It came back with '-Sg is not a recognised command' or something along those lines.

I then uninstalled and then reinstalled MySQL to see if it would clear the files with the passwords in them (which I can't find either), and I had no luck.

So, as you may have guessed, my simple question is how on earth can I reset or change the password if I've forgotten it?

Do I have to reinstall the entire OS again? Please say no....

Thank you in advance.
 
Old 12-17-2004, 04:48 PM   #2
mhiggins
Member
 
Registered: Feb 2004
Posts: 140

Rep: Reputation: 15
If you have no data bases define you can run mysql_install_db

this will wipe out your mysql db and reset everything.
 
Old 12-18-2004, 07:24 AM   #3
ronkymac
Member
 
Registered: Nov 2004
Location: Scotland
Distribution: Debian
Posts: 72

Original Poster
Rep: Reputation: 15
Wicked! Thanks ever so much mate,
I owe you a beer now!

Ronaldm.
 
Old 12-18-2004, 08:44 AM   #4
ronkymac
Member
 
Registered: Nov 2004
Location: Scotland
Distribution: Debian
Posts: 72

Original Poster
Rep: Reputation: 15
Oops, I probably said that too soon - it doesn't seem to have worked;

Would anyone on this forum have any idea as to how to get around this problem? I think it's just bad syntax or something...

What would I need to tell you to know where I'm going wrong? I.e. config files etc...?

Sorry if it seems obvious of something, I'm just a bit a newbie when it comes to SQL and Linux
 
Old 12-18-2004, 09:23 AM   #5
mhiggins
Member
 
Registered: Feb 2004
Posts: 140

Rep: Reputation: 15
I'm going to work for this beer!

We are going to take out the big sledge hammer now ! Find out where mysql installs its db's, on my system it is /var/lib/mysql
as root cd to /var/lib/mysql

rm -rf *

then run
mysql_install_db

## This is what it looks like when I run that command ##########

root@bartleby:/var/lib/mysql# mysql_install_db
Installing all prepared tables
041218 10:12:27 /usr/libexec/mysqld: Shutdown Complete


To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h bartleby password 'new-password'
See the manual for more instructions.

NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

######### End results

now lets make sure mysql can read its own db's

cd /var/lib
chown -R mysql:mysql mysql

make sure mysql is not running

killall mysqld

mysqld_safe &
<press enter>

now you can log into mysql w/o a password

try
mysql

you should be in ... since its bad to run your db w/o a password do the following

exit the mysql program
\q

then run the following command but replace new-password with something you will remember
but keep the single quotes.

/usr/bin/mysqladmin -u root password 'new-password'

now try
mysql -u root -p
when prompted enter your password!

ok that should do it !

-Matt
 
Old 12-18-2004, 09:40 AM   #6
ronkymac
Member
 
Registered: Nov 2004
Location: Scotland
Distribution: Debian
Posts: 72

Original Poster
Rep: Reputation: 15
Thank you ever so much, Matt!

Still came back with the same error though... this is what I did (I followed your method)

#####################################

linux:~ # rm -rf *
linux:~ # mysql_install_db
Installing all prepared tables
041218 15:28:15 /usr/sbin/mysqld: Shutdown Complete


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
This is done with:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h linux password 'new-password'
See the manual for more instructions.

NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!


You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

linux:~ # cd /var/lib
linux:/var/lib # chown -R mysql:mysql mysql
chown: `mysql:mysql': invalid group

##### I then created a group called 'mysql' and the users in the group were 'root' and 'server' ######

linux:/var/lib # chown -R mysql:mysql mysql
linux:/var/lib # killall mysqld
linux:/var/lib # mysqld_safe &
[3] 2572
linux:/var/lib # Starting mysqld daemon with databases from /var/lib/mysql
mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
linux:/var/lib # mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
linux:/var/lib # mysql -p
Enter password:

##### I then entered a blank password #####

ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)
linux:/var/lib #

########################################

Another thing worth mentioning is that when I ran all of this, it seemed to delete all the files on root's desktop; there was nothing there, of course, but it might be worth mentioning.

As ever, thank you very much.

Email me your addy so I can send you a beer

Ronaldm.
 
Old 12-19-2004, 04:18 PM   #7
ronkymac
Member
 
Registered: Nov 2004
Location: Scotland
Distribution: Debian
Posts: 72

Original Poster
Rep: Reputation: 15
Anyone??!
 
  


Reply



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
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 17 09-17-2014 02:13 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
samba printing- aaargh! linowes Linux - Networking 3 12-31-2002 06:40 PM
Windows (AAArgh) and MIDI Frauke General 3 10-28-2002 02:57 AM
aaargh eagle0669 Linux - Newbie 1 08-01-2001 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:42 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