I'm trying to reinstall mysql on my MAC OS X Yosemite. for this I followed the instruction as mentioned below
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySQL*
vim /etc/hostconfig and removed the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
I also tried
brew uninstall mysql
after this I installed mysql using homebrew using command brew install mysql
.
After installation when I tried to run mysql -u root
It throws the following error
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
I didn't set password for mysql.I don't know what's going wrong.Any suggestion will be appreciated. Thank you
Set root user password Login as user root with blank password >mysql -u root mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'abc';
The #1045 error is a phpMyAdmin authentication error that can be caused by an incorrectly typed username or password. To troubleshoot this error, you should complete a password reset and make sure you're using the correct database host name.
To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password'; Replace user_name with the user's username and password with the user's password.
Use the ALTER USER command and change the authentication method to log into MySQL as root: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; This command changes the password for the user root and sets the authentication method to mysql_native_password.
I installed mysql
with homebrew
and got the same problem as you because mysql
has had an existing database with an existing password there. See this article for more details.
$ brew services stop mysql
$ sudo pkill mysqld
$ sudo rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!!
$ brew postinstall mysql
$ brew services restart mysql
$ mysql -uroot
Now sql generates an aliatory password that appears in the last screen.
sudo mysql -u root -h 127.0.0.1 -p
Enter password: (aliatory password)
we can change it
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With