I've done a search on this, and though there are many results, all of the proposed solutions seem to fail for one reason or another.
One thing to note is that many of the solutions require entering mysql and then making some configuration changes to alter the user account. For the record, even so much as entering 'mysql' or 'mysql -u root' (and so on) at the command prompt will bring up the error.
I'm just using mysql for some big data classes, so I don't need a server and I don't need to connect any apps or anything like that (although I will be running HBase).
When I did the initial install:
sudo apt-get install mysql-server
I was never prompted for a password at any point. Likewise, if I run:
sudo dpkg-reconfigure mysql-server-5.7
I get the message:
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.19, use --force if you still need to run mysql_upgrade
Running it with '--force' just brings about the same error.
I've tried running:
sudo mysqld_safe --skip-grant-tables &
But I only get returned to the command prompt with "[1] 16654"
Just in case, I set chmod 777 on '/var/lib/mysql*' as well as '/var/run/mysqld'
I have also tried the unix instructions posted below, to no avail:
https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
The error log from /var/log/mysql was a bit unwieldy, so I have uploaded it here:
https://pastebin.com/exDeKHeA
Thanks in advance for any responses. If any other files or info is needed, please let me know.
Related
I am trying to get MySQL running on my localhost. This never happened to me before, but upon installation sudo apt-get install mysql-server did not ask me for the initial password.
After searching for answers to "reset" my password and battling with directory permissions, i am currently at this state:
The mysqld_safe solution:
After rebooting my computer, mysql -u root -p will ask me for my password, and after i enter it, it will complain with ERROR 1698 (28000): Access denied for user 'root'#'localhost'
If i instead try mysql -u root (no password), it will say ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
If i run the advice that other people have posted about resetting the password via mysqld_safe --skip-grant-tables, then i run across some hiccups along the way:
First i run sudo service mysql stop
Then sudo mysql_safe --skip-grant-tables will say mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
I can fix that if i do sudo mkdir -p /var/run/mysqld and sudo chown mysql /var/run/mysqld
After this, running mysqld_safe will run with the message Starting mysqld daemon with databases from /var/lib/mysql and then hang. And Ctrl+C doesn't get me out of that.
In a new terminal window i can now actually connect with mysql -u root and get the mysql> prompt.
I can set a new password with use mysql; update user set authentication_string=password('0000') where user='root';flush privileges; which will tell me it successfully updated the row with the message Rows matched: 1 Changed: 1 Warnings: 1
The warning only states: 'PASSWORD' is deprecated and will be removed in a future release.
And after all this, i'm back at square one: The process still hangs, so i have to reboot because killall mysqld_safe says no process found. After rebooting and entering my new password 0000, i will get access denied.
The system is Linux 4.15.0-48-generic #51-Ubuntu SMP.
The mysqladmin solution
If i run mysqladmin -u root password '0000' (without sudo), i get:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost''
If i run it with sudo, i get:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
This last one doesn't really tell me anything in regards of whether the password change happened or not; has it been refused or not (since it's a warning, not an error, i would assume it should go through), but in either case, trying to connect with 0000 still says "access denied".
Any advice on how to fix this is greatly appreciated.
I didn't quite solve the problems with mysql directly; However for myself, the acceptable solution was switching to a different database software, but it's still a MySQL system, and it got me up and running. So if anyone gets stuck on existing solutions not working like i did, maybe this comes in handy to get you on the road and finally writing code again.
What i did was:
Purged mysql off my system
Manually deleted /etc/mysql and /var/lib/mysql (don't know if this step was necessary)
apt clean, apt autoremove, apt update
Installed mariadb
Followed these instructions to rid myself of the timeout bug
Used the mysqld_safe --skip-grant-tables method to create a new user with all privileges, since connecting with root always kept failing
PHP + MariaDB now working again.
I seem to be unable to set a valid MySQL root password that Phabricator can use during the installation.
Every time I try to restart the phd daemons (as per these instructions: https://gist.github.com/sparrc/b4eff48a3e7af8411fc1) I get the following exception:
[2018-09-20 08:38:09] EXCEPTION: (PhabricatorClusterStrandedException) Unable to establish a connection to any database host (while trying "phabricator_config"). All masters and replicas are completely unreachable.
AphrontConnectionQueryException: Attempt to connect to root#127.0.0.1 failed with error #1698: Access denied for user 'root'#'localhost'. at [<phabricator>/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php:158]
I was, however, able to successfully complete the ./bin/storage upgrade Phabricator command after reinstalling MySQL.
I have tried:
sudo dpkg-reconfigure mysql-server-5.7 - Didn't prompt for a new password
Logging in with mysqld_safe --skip-grant-tables & and running update commands on the root password. All seems to be successful, but as soon as I try Phabricator again, I get the exception.
Looking for temporary passwords:
sudo grep "temporary password" /var/log/mysqld.log
grep: /var/log/mysqld.log: No such file or directory
Note that I am using ./bin/config set mysql.pass 'mypassword' after changing it using any of the methods above. I've tried no password as well, which doesn't work. Once I have run the Phabricator storage upgrade command, I can no longer access mySQL at all and any steps to reset passwords seem to take no effect.
I'm running MySQL 5.7 and PHP 5.6 on Ubuntu 18.04
I downloaded MySQL 5.7.17 for Mac and installed it. I can start and stop the SQL server from my Preferences > MySQL. It is shown as an instance on port 3306 from Workbench so all that seems fine. However, during install toward the end a pop-up window listed a password I was supposed to use. I assumed it would be promptly needed so copied on the clipboard. Few mins later having not been prompted for it yet, I copied something else in the clipboard thus losing it.
I have been trying to get some sort of client of mysql command line so I can enter sql commands, however there is no "Application" installed to use to access the server. I have scoured the MySQL documentation and Stack and beyond, and searched for how to get the password reset, and a mysql client/command line, but all the articles seem to assume you already have access to a "MySQL terminal"/"command line". I only have access to my normal Mac Terminal, and most commands in the normal Terminal window either fail or require the password I don't have, for example:
$ mysqld --skip-grant-tables
-bash: mysqld: command not found
$ mysql -u root -p
-bash: mysql: command not found
$ sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'
Password: (this is probably the password I was given that got overwritten? When I try the admin password of the machine it sends me back to the prompt)
$ sudo mysqld_safe --skip-grant-tables (after I'd stopped the server)
sudo: mysqld_safe: command not found
Can somebody please help me figure out how to get to a "MySql Terminal" and if I need this password that got overwritten, how to reset it? (it seems like uninstalling MySQL to repeat the steps and this time take better care of the password is actually horrendously difficult / no uninstall protocol?).
Thank you so very much.
--- Update: I used the How To Uninstall suggested by Josh M and then re-installed. This time I saved the password (so far, not sure how / where I need to use it). However, I must really be missing something b/c I still can't get access to mysql.
/usr/local/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'Robert'#'localhost' (using password: NO)
Then I did $ export PATH=$PATH:/usr/local/mysql/bin but I still get ERROR 1045.
Try these set of commands
$ sudo /usr/local/mysql/support-files/mysql.server stop
$ sudo /usr/local/mysql/support-files/mysql.server start --skip-grant-tables
/usr/local/mysql/bin/mysql
FLUSH PRIVILEGES;
ALTER USER 'root'#'localhost' IDENTIFIED BY 'YOUR_NEW_PASSWORD';
EXIT;
$ sudo /usr/local/mysql/support-files/mysql.server stop
$ sudo /usr/local/mysql/support-files/mysql.server start
$ mysql -u root -p
$ Enter Password: 👉🏻 ENTER_YOUR_NEW_PASSWORD_HERE 👈🏻
And enjoy 🎉
There's a tutorial for resetting passwords here: https://www.howtoforge.com/setting-changing-resetting-mysql-root-passwords
Your MySQL command line interface (cli) is probably at:
/usr/local/mysql/bin/mysql
Honestly it might be better to reinstall. There's an SO on that: How do you uninstall MySQL from Mac OS X?
I went through all similar or identical questions (this and this, for ex.) but still can't solve the problem.
I am on Xenial and have MySQL 5.7.12. I do not remember setting any password during installation (if it asked, I provided empty one).
I tried to go through password reset using --skip-grant-tables, as described here, it updated the database row, but I still cannot login.
Reconfiguring with sudo dpkg-reconfigure mysql-server-5.7 doesn't do anything, I get this:
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.12, use --force if you still need to run mysql_upgrade
$ sudo dpkg-reconfigure --force mysql-server-5.7
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.12, use --force if you still need to run mysql_upgrade
Any ideas?
MySQL 5.7 generates a random root password by itself on installation.
This was a new change in MySQL 5.7.4, and described in the release notes: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-4.html
The installation process creates only a single root account,
'root'#'localhost', automatically generates a random password for this
account, and marks the password expired. The MySQL administrator must
connect as root using the random password and use SET PASSWORD to
select a new password. (The random password is found in the
.mysql_secret file in the home directory of the effective user running
the script.)
I never find the .mysql_secret file, but the random password is also output in the MySQL error log (e.g. /var/log/mysqld.log on Linux). The notice looks like this:
2016-07-11T15:59:54.922316Z 1 [Note] A temporary password is generated for root#localhost: f14_W1lN7FfP
You could either reinstall everything, which i did. I had initially installed using macos package installer. That didn't get me anywhere.
So uninstalled everything, then upgraded brew, and installed via brew. Running the mysql shell proved a messy affair. Ultimately what worked was mysql -u root -p.
I was running it on localhost, so turns out root password wasn't required. Weirdly, mysql -u root -p <password> threw the "access denied" message.
Proper re-installing helped. Removed everything associated (this instruction, but it is important to specify the version of mysql, e.g. apt-get --yes purge mysql-server-5.7 mysql-client-5.7, and I also deleted mysql-common and all dependencies to be sure).
Then installed again (apt-get install mysql-server mysql-client) and when it asked for a password, this time, I gave it one. It works now.
I'm new to setting up my own database server and linux server, but I'm working on a project that needs to use phpCake and mysql. I have a turnkey linux install of LAMP, with phpCake installed on it. My Cake install is fine, however I can not get into mysql.
mysql command yields error 1045, access denied for user root#localhost using password: no
mysql -u root -p
'rootpasswordhere'
yeilds the same thing, except using password:yes
I've read many fixes involving stoping mysql and setting a new password. I've had none of those work for me. The mysql stop command is denied in the same way the mysql command is. When I use service stop mysql my input cursor gets strange and no longer captures any input.
I'd love any help or input. I'll try out any of the fixes out there again and detail what happens. I'm sorry if this has been answered before, but trying the fixes I've found over the last few hours don't seem to work. Unsure if it is me, or my actual problem.
Thanks!
Depending on which linux you are running:
Stop service:
sudo service mysqld stop
Run these commands to write a temporary SQL file (/tmp/my.sql):
sudo echo "UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';" > /tmp/my.sql
sudo echo "FLUSH PRIVILEGES;" >> /tmp/my.sql
Start the service with script:
sudo /usr/bin/mysqld_safe --init-file=/tmp/my.sql &
---------------------------------------------------------------------------------^ The ampersand runs the process in the background allowing you to continue using the terminal.
Now you should be able to connect with your new root password MyNewPass
Note: Be sure to a) change the root password and b) remove /tmp/my.sql once completed.