How to fix root password problem ?

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
newphper
Forum Commoner
Posts: 26
Joined: Mon Mar 21, 2011 1:48 am
Location: Bridgeman Downs, Qld, Australia

How to fix root password problem ?

Post by newphper »

Hello,
I just reinstalled snow leopard and am having some problems logging into mysql now.
Does anyone know the answer to this problem ?
Below is what happens when I try to login through terminal

Last login: Mon May 30 06:09:35 on ttys000
reg:~ regellis$ /Library/StartupItems/MySQLCOM/MySQLCOM start;
Starting MySQL database server
reg:~ regellis$ mysql;
-bash: mysql: command not found
reg:~ regellis$ /usr/local/mysql/bin/mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
reg:~ regellis$


Below is what happens when I try to view the directory/folder
When I try to "go to" "/usr/local/mysql/bin/mysql" a message pops up
The folder “mysql” can’t be opened because you don’t have permission to see its contents.
I always log into my mac as administrator…………
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to fix root password problem ?

Post by VladSun »

Run MySQL daemon with --skip-grant-tables option, change root password and restart the server.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: How to fix root password problem ?

Post by Weirdan »

It doesn't seem to be a problem with password though - mysql cannot connect via socket, which most likely means the socket is not there (server not running or using different path).

Run

Code: Select all

ps aux | grep mysqld
look for the daemon process and note the path to it.

Then run

Code: Select all

$PATH_YOU_NOTED/mysql_config
and note the path in '--socket' section

run

Code: Select all

/usr/local/mysql/bin/mysql -S $SOCKET_PATH $ANY_OTHER_ARGUMENTS
Now it should connect successfully. If it complains about wrong password, follow the VladSun's advice.
newphper
Forum Commoner
Posts: 26
Joined: Mon Mar 21, 2011 1:48 am
Location: Bridgeman Downs, Qld, Australia

Re: How to fix root password problem ?

Post by newphper »

Thank you for your help and advice, I actually used time machine to fix the problem.

For the time being it was the easiest way until I learn more about the MySql commands.

I also found a tool called Tinker Tool, this seems a handy program for macs, have only had my first mac for 2 months now.
Post Reply