3

Let me start by saying that I've looked through tons of posts (both here and elsewere on the internet and the article on mysql.com about resetting the admin password) about resetting the mysql password, but nothing seems to work for me. Oh, i'm also fairly new to working on the command line.

Below the 'solution' that seems to work for everyone, but not for me:


Last login: Mon Nov  3 12:02:21 on console
maurice@Maurices-MacBook-Pro:~$ sudo /usr/local/mysql/support-files/mysql.server stop
Password:
Shutting down MySQL
. SUCCESS! 
maurice@Maurices-MacBook-Pro:~$ sudo mysqld_safe --skip-grant-tables
141103 12:25:35 mysqld_safe Logging to '/usr/local/mysql/data/Maurices-MacBook-Pro.local.err'.
141103 12:25:35 mysqld_safe A mysqld process already exists
maurice@Maurices-MacBook-Pro:~$ 

I don't know where that other process is coming from and i have no clue on how to close that. If i continue to follow the instructions and open a new console tab i get the following:


Last login: Mon Nov  3 12:25:16 on ttys000
maurice@Maurices-MacBook-Pro:~$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
maurice@Maurices-MacBook-Pro:~$ sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
maurice@Maurices-MacBook-Pro:~$ 

I can't get into mysql to update the password. I can communicate with MySQL via the mysql command, but (of course) i can't do any queries:


maurice@Maurices-MacBook-Pro:~$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
ERROR 1142 (42000): UPDATE command denied to user ''@'localhost' for table 'user'
mysql> 

I've spent the whole yesterday evening searching for solutions, but can't find anything anywhere. Please remember that i'm fairly new to working on the command line, so if i overlook something really basic; sorry!

I really hope someone knows a solution, because i'm out of options

Edit (solution): Paul Haldane pointed me in the right directions. I forgot that i've added an com.mysql.mysql.plist file that i loaded via launchctl on startup to autostart MySQL on startup. First doing an sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysql.plist stopped MySQL and let me login in safe mode.

So happy right now :)

Maurice
  • 143
  • 1
  • 1
  • 7

1 Answers1

4

That behaviour implies that there's a MySQL daemon already running when you try to start the new one without authentication. There are two possible causes for this. 1. the mysql.server stop command isn't working despite reporting success or 2. there's a supervisor process running which automatically restarts the server if it dies. You should be able to tell which is happening to you by looking at running processes using ps. Try

ps uaxww | grep -i mysql

That will give you list of processes. If the main mysqld has been running for a while then it's cause 1, if it just started then likely to be cause 2. Either way kill off the processes using the kill command (via sudo). Just normal kill - don't use -9 as it won't give MySQLd a chance to shutdown cleanly. After that you should be able to start the daemon without authentication.

Paul Haldane
  • 4,457
  • 1
  • 20
  • 31