MySql Labyrinth

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Moron!
Forum Newbie
Posts: 3
Joined: Tue Apr 04, 2006 2:55 pm

MySql Labyrinth

Post by Moron! »

PREFACE:

My name is Al and I'm a <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> moron who locked himself out of MySql. Alright, Let's rock.

I don't exactly remember changing my password, but since I was in the Terminal using commands like -u password, I think I might have done it on accident.

So... I need to change it back. And I don't want a work-around because I'm <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> frustrated and confused and I want I back to normal, which I must confess: Was anything but normal when it was normal.

WHY I'M A MORON:

Two weeks ago, I couldn't have told you where my bin folder was located... Now I can tell you where 5 of them are. As well as 3 mysql, 2 apache & 8 php folders. So when you say "Hey, put the file in the php and connect it to the thing" please tell me which folder, so I don't crack my god damn head on the screen again.

Lost In translation: I understand YourPasswordHere. I'm not an idiot, I'm a moron. When you start adding quotations and parenthesis around it, I'll assume that I'm supposed to add those. I understand alot better when thing are highlighted in bold.


DETAILS:
Macintosh G5 running OS 10.4.5
My "former" MySql password is root and I want it back.
My apple username and password: albert/apple
I have 3 versions of mysql installed and they are:

mysql-standard-5.0.19-osx10.4-powerpc
mysql-standard-5.0.19-osx10.4-powerpc-64bit
mysql-standard-4.1.18-apple-darwin8.2.0-powerpc
PHP version 4
PHP version 5


TROUBLE SHOOTING:
Every single thing in the world I have tried has resulted in the same two errors:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)



BEEN THERE DONE THAT:
People kept telling me to downloaded this Mamp thing and that it would somehow solve all of my php/mysql problems. Well, it did for about a week until this whole password thing went down. I first noticed there was a problem when I tried to start Mamp the other day and got the red MySql light and the green Apache light. When I tried to open the Mamp start page it says: Error: Could not connect to MySQL server!

So I tried to reset my password:
/Applications/MAMP/bin/mysql4/bin/mysqladmin -u root -p password

Grant privileges:
mysql GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'

following the MySql instructions:
mac:~ albert$ mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');

And got me this:
-bash: syntax error near unexpected token `('
mac:~ albert$ <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> u
-bash: <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>: command not found

And every other command in the book.
And people keep telling me to type commands, but they're not telling me what to type when it asks me for my password. The typical forum guy comes along and is like "Hey buddy, type this in the Terminal" and when I come back to tell him it asked me for my password, he's gone with the wind.


So, in attempt to restore my username and password I decided to uninstall everything:
1) I tried to uninstall Mamp by deleting the Mamp folder.
2) I tried to uninstall all 3 accounts of MySql by deleting the folders from /usr folder and deleted the preference pane.

And with my capacity, I think that's the way to go... Only problem is, it didn't reinstall the root user.

I even checked the the "official" MySql manual. With over 5,000 pages, they should consider renaming it to the MySql Labyrinth.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I'm pretty sure if you search for "mysql lost password" you'll find the answer as that's the title of the page that explains it. And i'm sure i've already posted the URL in this forum too...
Moron!
Forum Newbie
Posts: 3
Joined: Tue Apr 04, 2006 2:55 pm

Post by Moron! »

People have been very kind and done some Googling for me, but I can't find the answer.
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

Moron!
Forum Newbie
Posts: 3
Joined: Tue Apr 04, 2006 2:55 pm

Post by Moron! »

Thanks, but I've been there 100 times.

I cant even get past step 2:

Code: Select all

Locate the .pid file that contains the server's process ID. The exact location and name of this file depend on your distribution, hostname, and configuration. Common locations are /var/lib/mysql/, /var/run/mysqld/, and /usr/local/mysql/data/. Generally, the filename has the extension of .pid and begins with either mysqld or your system's hostname.

You can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the pathname of the .pid file in the following command:

shell> kill `cat /mysql-data-directory/host_name.pid`

Note the use of backticks rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.
The so called data folder is locked.
I opened it by changing it's permissions but there's nothing in there. No stupid pid file. :angry:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I would just do a clean install, removing all trace from previous databases. Seems like you have so much clutter, its dificult to find referenced files.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Your .pid file could be anywhere and essentially be called anything one place which I find quite common that hasn't be mentioned is in /tmp i.e. /tmp/hostname.pid there are other ways to find this file rather than manually searching.

First thing you need to know is which of your MySQL installs is actually running so from the terminal type....

Code: Select all

ps ax | grep mysql
... this should return a few lines, one of which will mention the mysqld executable (and hopefully full path to it) you may have to resize your terminal window to see the full line but it may look something like this.....

Code: Select all

/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
... there are probably a few more options on that line, but it's the fisrt part which concerns you and you should take note of that path to your mysql bin directory.

The other line of interest is the mysqld_safe executable line which will look something like this....

Code: Select all

/bin/sh ./bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/hostname.pid
... take a note of the additional options passed to the executable as you'll need them later, this should also give you the path to your .pid file so now you can kill/stop the currently running MySQL process by typing.....

Code: Select all

kill `cat /path/to/your/hostname.pid`
... if this throws an error (i.e. permission denied) then try...

Code: Select all

sudo cat /path/to/your/hostname.pid
..when prompted for your password you should type the password of a user with admin rights to the machine. This will give you the actual PID of the MySQL running process (you can also get this from the output of the ps ax command you ran earlier. So, take that number and type....

Code: Select all

sudo kill PIDnumber
Create an SQL file for reseting the password by typing....

Code: Select all

echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpasswordhere');" > reset-pass
Now restarting via mysqld_safe executable and passing in the extra file within the options, using the example output from above the command would be......

Code: Select all

sudo /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/hostname.pid --init-file=/full/path/to/the/file/reset-pass &
... the last command above should be typed on a single line.
Post Reply