Problem with mysql root password
I am on Ubuntu 16.04 LTS. What is my mysql root password? If I enter
mysql -u root -p
It asks me to enter a password: I don't know it, and no password won't work either. Mysql was pre-installed, so I didn't choose any root password. If I try to install it again, with
sudo apt-get install mysql-server
It says that mysql-server is already the newest version (5.7.18-0ubuntu0.16.04.1)
Any help, hints? Thanks.
mysql password root
add a comment |
I am on Ubuntu 16.04 LTS. What is my mysql root password? If I enter
mysql -u root -p
It asks me to enter a password: I don't know it, and no password won't work either. Mysql was pre-installed, so I didn't choose any root password. If I try to install it again, with
sudo apt-get install mysql-server
It says that mysql-server is already the newest version (5.7.18-0ubuntu0.16.04.1)
Any help, hints? Thanks.
mysql password root
this link has all in it-> dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
– Akhil Varma
Jul 1 '17 at 17:27
add a comment |
I am on Ubuntu 16.04 LTS. What is my mysql root password? If I enter
mysql -u root -p
It asks me to enter a password: I don't know it, and no password won't work either. Mysql was pre-installed, so I didn't choose any root password. If I try to install it again, with
sudo apt-get install mysql-server
It says that mysql-server is already the newest version (5.7.18-0ubuntu0.16.04.1)
Any help, hints? Thanks.
mysql password root
I am on Ubuntu 16.04 LTS. What is my mysql root password? If I enter
mysql -u root -p
It asks me to enter a password: I don't know it, and no password won't work either. Mysql was pre-installed, so I didn't choose any root password. If I try to install it again, with
sudo apt-get install mysql-server
It says that mysql-server is already the newest version (5.7.18-0ubuntu0.16.04.1)
Any help, hints? Thanks.
mysql password root
mysql password root
edited Jul 1 '17 at 14:12
A. N. Other
asked Jul 1 '17 at 14:05
A. N. OtherA. N. Other
14218
14218
this link has all in it-> dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
– Akhil Varma
Jul 1 '17 at 17:27
add a comment |
this link has all in it-> dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
– Akhil Varma
Jul 1 '17 at 17:27
this link has all in it-> dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
– Akhil Varma
Jul 1 '17 at 17:27
this link has all in it-> dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
– Akhil Varma
Jul 1 '17 at 17:27
add a comment |
4 Answers
4
active
oldest
votes
Two options:
First is purging mysql(only if you don't already have a database):
Use
apt-get purge mysql-server
to purge and then
apt-get install mysql-server
to simply reinstall it. While installing it should ask you for a password. This is the easiest and fastest way, however it could come to problems if some programs like phpmyadmin already connected to the existing MySQL so I'd suggest you to use the
Or do the following: Stop the MySQL Server using
sudo service mysql stop
Then start the safe mode with
sudo /usr/bin/mysqld_safe --skip-grant-tables &
Select localhost as host(After the last command there won't be a command prompt, so after the message Starting mysqld daemon with databases from [...]
type in the next command)
mysql -h localhost
select mysql with
USE mysql
(Replace YOURNEWPASSWORD with your new password!) Type
UPDATE mysql.user
SET authentication_string=PASSWORD('new_password')
WHERE user='root' AND host='localhost';
Exit with
quit
And restart MySQL with
sudo mysqladmin shutdown
sudo service mysql start
Edit
That error has something to do with your MySQL socket. First you want to find all socket files on your system with:
sudo find / -type s
Your socket should be something similar to this
/var/lib/mysql/mysql.sock
(important is the /mysql.sock
part)
Once you find where the socket is being opened, add or edit the line to your
/etc/my.cnf
file with the path to the socket file:
put
[mysqld]
at the very beginning and
socket=/path/to/your/socket/
at the very end of the file.
Try the 2. option again now. If it doesn't work continue with this explanation.
If this doesn't solve your problem something overrides the my.cnf location, and that would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work.
To fix this start with shutting down the mysqld
process
pkill -9 mysqld
After you do this you might want to look for a pid file in /var/run/mysqld/ and delete it
Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:
chmod 755 /var/run/mysqld/mysqld.sock
Sources:
https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
https://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/
https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq
When I try to log in as root (step 3 of option 2) it says -- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [1]+ Exit 1 -- is it ok?
– A. N. Other
Jul 2 '17 at 5:43
@A.N.Other edited my answer a bit
– ADDB
Jul 2 '17 at 7:20
I see only /run/mysqld/mysqld.sock in the socket list with mysql in their name...That's a bit different from the one you suggest...If you think that's ok, I'll go forward with your suggestions. Thanks.
– A. N. Other
Jul 2 '17 at 7:47
It's okay. I only said something similar.
– ADDB
Jul 2 '17 at 7:48
I put the new line with the path into the /etc/mysql/my.cnf. Then, after the "skip-grant-tables" it says: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23! mysqld: [ERROR] Fatal error in defaults handling. Program aborted! -- there is also a mysql.cnf.d dir that contains other .cnf files... mysqld.cnf mysqld_safe_syslog.cnf -- Should I edit them all?
– A. N. Other
Jul 2 '17 at 8:03
|
show 4 more comments
For the new my-sql 5.7 if password is left empty then it uses auth_plugin.
In that case login with sudo
privilege.
$ sudo mysql -u root -p
After login you can simply use this to update password.
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
For complete refrence check here.
EDIT:
One can also use this (without -u root
):
$ sudo mysql
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
It works also without the option-u root
he chooses automatically root. And you can leave the option-p
out. You just need to enter the sudo password, no mysql-root password
– Boba Fit
Aug 15 '18 at 21:28
add a comment |
For MySQL 5.7, the default password is printed in the logs.
A quick grep can return it.
grep 'temporary password' /var/log/mysqld.log
References:
https://www.percona.com/blog/2016/05/18/where-is-the-mysql-5-7-root-password/
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
https://stackoverflow.com/questions/33991228/what-is-the-default-root-pasword-for-mysql-5-7
https://dba.stackexchange.com/questions/127537/setting-root-password-in-fresh-mysql-5-7-installation
grep: /var/log/mysqld.log: "No such file or directory". I have /var/log/mysql and then "error.log error.log.2.gz error.log.4.gz error.log.6.gz error.log.1.gz error.log.3.gz error.log.5.gz error.log.7.gz"
– A. N. Other
Jul 1 '17 at 14:35
Try it on /var/log/mysql/error.log, then. It's just a different log name. Do any of the files around there come up with an answer? The file that you're logging to is likely somewhere in the conf file for MySQL which should be somewhere like "/etc/mysql/mysql.conf.d/mysqld.cnf"
– Bujiraso
Jul 1 '17 at 14:37
With 'temporary password' none, if i grep 'password' there is: 'Shutting down plugin 'sha256_password' and 'Shutting down plugin 'mysql_native_password', but no actual password
– A. N. Other
Jul 1 '17 at 14:42
I would do a quick "zgrep temporary *" in that dir and if that turns up nothing, follow the steps here to by-pass the access rights and set a new root password. Further detailed resetting instructions are on the MySQL docs
– Bujiraso
Jul 1 '17 at 14:46
All the info is actually distribution-dependent, and at this stage I am at a loss on what to do in my case. I wonder if anyone who wants to try mysql on Linux has to go through all of this?!?!
– A. N. Other
Jul 1 '17 at 16:01
|
show 1 more comment
UBUNTU 16.04 and MYSQL 5.7.20
I did not find ADDB's instructions completely helpful. After searching I discovered the following (a small re-write for Option 2):
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set authentication_string=PASSWORD("NEW_PASSWORD_GOES_HERE") where User='root';
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Reference: http://rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts/
My preferred method:
I used the Mysql user "debian-sys-maint" (a root equivelant). The password can be found in /etc/mysql/debian.cnf. After logging into Mysql as this user change the password for any Mysql user.
USE mysql
SELECT root@localhost;
ALTER USER user IDENTIFIED BY 'auth_string';
ALTER USER 'Name_of_user_to_be_modified'@'Hostname (ie:localhost)' IDENTIFIED BY 'NEW_PASSWORD';
flush privileges;
exit;
Reference:
https://serverfault.com/questions/9948/what-is-the-debian-sys-maint-mysql-user-and-more
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f931001%2fproblem-with-mysql-root-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Two options:
First is purging mysql(only if you don't already have a database):
Use
apt-get purge mysql-server
to purge and then
apt-get install mysql-server
to simply reinstall it. While installing it should ask you for a password. This is the easiest and fastest way, however it could come to problems if some programs like phpmyadmin already connected to the existing MySQL so I'd suggest you to use the
Or do the following: Stop the MySQL Server using
sudo service mysql stop
Then start the safe mode with
sudo /usr/bin/mysqld_safe --skip-grant-tables &
Select localhost as host(After the last command there won't be a command prompt, so after the message Starting mysqld daemon with databases from [...]
type in the next command)
mysql -h localhost
select mysql with
USE mysql
(Replace YOURNEWPASSWORD with your new password!) Type
UPDATE mysql.user
SET authentication_string=PASSWORD('new_password')
WHERE user='root' AND host='localhost';
Exit with
quit
And restart MySQL with
sudo mysqladmin shutdown
sudo service mysql start
Edit
That error has something to do with your MySQL socket. First you want to find all socket files on your system with:
sudo find / -type s
Your socket should be something similar to this
/var/lib/mysql/mysql.sock
(important is the /mysql.sock
part)
Once you find where the socket is being opened, add or edit the line to your
/etc/my.cnf
file with the path to the socket file:
put
[mysqld]
at the very beginning and
socket=/path/to/your/socket/
at the very end of the file.
Try the 2. option again now. If it doesn't work continue with this explanation.
If this doesn't solve your problem something overrides the my.cnf location, and that would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work.
To fix this start with shutting down the mysqld
process
pkill -9 mysqld
After you do this you might want to look for a pid file in /var/run/mysqld/ and delete it
Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:
chmod 755 /var/run/mysqld/mysqld.sock
Sources:
https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
https://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/
https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq
When I try to log in as root (step 3 of option 2) it says -- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [1]+ Exit 1 -- is it ok?
– A. N. Other
Jul 2 '17 at 5:43
@A.N.Other edited my answer a bit
– ADDB
Jul 2 '17 at 7:20
I see only /run/mysqld/mysqld.sock in the socket list with mysql in their name...That's a bit different from the one you suggest...If you think that's ok, I'll go forward with your suggestions. Thanks.
– A. N. Other
Jul 2 '17 at 7:47
It's okay. I only said something similar.
– ADDB
Jul 2 '17 at 7:48
I put the new line with the path into the /etc/mysql/my.cnf. Then, after the "skip-grant-tables" it says: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23! mysqld: [ERROR] Fatal error in defaults handling. Program aborted! -- there is also a mysql.cnf.d dir that contains other .cnf files... mysqld.cnf mysqld_safe_syslog.cnf -- Should I edit them all?
– A. N. Other
Jul 2 '17 at 8:03
|
show 4 more comments
Two options:
First is purging mysql(only if you don't already have a database):
Use
apt-get purge mysql-server
to purge and then
apt-get install mysql-server
to simply reinstall it. While installing it should ask you for a password. This is the easiest and fastest way, however it could come to problems if some programs like phpmyadmin already connected to the existing MySQL so I'd suggest you to use the
Or do the following: Stop the MySQL Server using
sudo service mysql stop
Then start the safe mode with
sudo /usr/bin/mysqld_safe --skip-grant-tables &
Select localhost as host(After the last command there won't be a command prompt, so after the message Starting mysqld daemon with databases from [...]
type in the next command)
mysql -h localhost
select mysql with
USE mysql
(Replace YOURNEWPASSWORD with your new password!) Type
UPDATE mysql.user
SET authentication_string=PASSWORD('new_password')
WHERE user='root' AND host='localhost';
Exit with
quit
And restart MySQL with
sudo mysqladmin shutdown
sudo service mysql start
Edit
That error has something to do with your MySQL socket. First you want to find all socket files on your system with:
sudo find / -type s
Your socket should be something similar to this
/var/lib/mysql/mysql.sock
(important is the /mysql.sock
part)
Once you find where the socket is being opened, add or edit the line to your
/etc/my.cnf
file with the path to the socket file:
put
[mysqld]
at the very beginning and
socket=/path/to/your/socket/
at the very end of the file.
Try the 2. option again now. If it doesn't work continue with this explanation.
If this doesn't solve your problem something overrides the my.cnf location, and that would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work.
To fix this start with shutting down the mysqld
process
pkill -9 mysqld
After you do this you might want to look for a pid file in /var/run/mysqld/ and delete it
Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:
chmod 755 /var/run/mysqld/mysqld.sock
Sources:
https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
https://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/
https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq
When I try to log in as root (step 3 of option 2) it says -- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [1]+ Exit 1 -- is it ok?
– A. N. Other
Jul 2 '17 at 5:43
@A.N.Other edited my answer a bit
– ADDB
Jul 2 '17 at 7:20
I see only /run/mysqld/mysqld.sock in the socket list with mysql in their name...That's a bit different from the one you suggest...If you think that's ok, I'll go forward with your suggestions. Thanks.
– A. N. Other
Jul 2 '17 at 7:47
It's okay. I only said something similar.
– ADDB
Jul 2 '17 at 7:48
I put the new line with the path into the /etc/mysql/my.cnf. Then, after the "skip-grant-tables" it says: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23! mysqld: [ERROR] Fatal error in defaults handling. Program aborted! -- there is also a mysql.cnf.d dir that contains other .cnf files... mysqld.cnf mysqld_safe_syslog.cnf -- Should I edit them all?
– A. N. Other
Jul 2 '17 at 8:03
|
show 4 more comments
Two options:
First is purging mysql(only if you don't already have a database):
Use
apt-get purge mysql-server
to purge and then
apt-get install mysql-server
to simply reinstall it. While installing it should ask you for a password. This is the easiest and fastest way, however it could come to problems if some programs like phpmyadmin already connected to the existing MySQL so I'd suggest you to use the
Or do the following: Stop the MySQL Server using
sudo service mysql stop
Then start the safe mode with
sudo /usr/bin/mysqld_safe --skip-grant-tables &
Select localhost as host(After the last command there won't be a command prompt, so after the message Starting mysqld daemon with databases from [...]
type in the next command)
mysql -h localhost
select mysql with
USE mysql
(Replace YOURNEWPASSWORD with your new password!) Type
UPDATE mysql.user
SET authentication_string=PASSWORD('new_password')
WHERE user='root' AND host='localhost';
Exit with
quit
And restart MySQL with
sudo mysqladmin shutdown
sudo service mysql start
Edit
That error has something to do with your MySQL socket. First you want to find all socket files on your system with:
sudo find / -type s
Your socket should be something similar to this
/var/lib/mysql/mysql.sock
(important is the /mysql.sock
part)
Once you find where the socket is being opened, add or edit the line to your
/etc/my.cnf
file with the path to the socket file:
put
[mysqld]
at the very beginning and
socket=/path/to/your/socket/
at the very end of the file.
Try the 2. option again now. If it doesn't work continue with this explanation.
If this doesn't solve your problem something overrides the my.cnf location, and that would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work.
To fix this start with shutting down the mysqld
process
pkill -9 mysqld
After you do this you might want to look for a pid file in /var/run/mysqld/ and delete it
Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:
chmod 755 /var/run/mysqld/mysqld.sock
Sources:
https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
https://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/
https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq
Two options:
First is purging mysql(only if you don't already have a database):
Use
apt-get purge mysql-server
to purge and then
apt-get install mysql-server
to simply reinstall it. While installing it should ask you for a password. This is the easiest and fastest way, however it could come to problems if some programs like phpmyadmin already connected to the existing MySQL so I'd suggest you to use the
Or do the following: Stop the MySQL Server using
sudo service mysql stop
Then start the safe mode with
sudo /usr/bin/mysqld_safe --skip-grant-tables &
Select localhost as host(After the last command there won't be a command prompt, so after the message Starting mysqld daemon with databases from [...]
type in the next command)
mysql -h localhost
select mysql with
USE mysql
(Replace YOURNEWPASSWORD with your new password!) Type
UPDATE mysql.user
SET authentication_string=PASSWORD('new_password')
WHERE user='root' AND host='localhost';
Exit with
quit
And restart MySQL with
sudo mysqladmin shutdown
sudo service mysql start
Edit
That error has something to do with your MySQL socket. First you want to find all socket files on your system with:
sudo find / -type s
Your socket should be something similar to this
/var/lib/mysql/mysql.sock
(important is the /mysql.sock
part)
Once you find where the socket is being opened, add or edit the line to your
/etc/my.cnf
file with the path to the socket file:
put
[mysqld]
at the very beginning and
socket=/path/to/your/socket/
at the very end of the file.
Try the 2. option again now. If it doesn't work continue with this explanation.
If this doesn't solve your problem something overrides the my.cnf location, and that would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work.
To fix this start with shutting down the mysqld
process
pkill -9 mysqld
After you do this you might want to look for a pid file in /var/run/mysqld/ and delete it
Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:
chmod 755 /var/run/mysqld/mysqld.sock
Sources:
https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
https://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/
https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq
edited 2 days ago
zev
1034
1034
answered Jul 1 '17 at 17:19
ADDBADDB
1,212517
1,212517
When I try to log in as root (step 3 of option 2) it says -- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [1]+ Exit 1 -- is it ok?
– A. N. Other
Jul 2 '17 at 5:43
@A.N.Other edited my answer a bit
– ADDB
Jul 2 '17 at 7:20
I see only /run/mysqld/mysqld.sock in the socket list with mysql in their name...That's a bit different from the one you suggest...If you think that's ok, I'll go forward with your suggestions. Thanks.
– A. N. Other
Jul 2 '17 at 7:47
It's okay. I only said something similar.
– ADDB
Jul 2 '17 at 7:48
I put the new line with the path into the /etc/mysql/my.cnf. Then, after the "skip-grant-tables" it says: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23! mysqld: [ERROR] Fatal error in defaults handling. Program aborted! -- there is also a mysql.cnf.d dir that contains other .cnf files... mysqld.cnf mysqld_safe_syslog.cnf -- Should I edit them all?
– A. N. Other
Jul 2 '17 at 8:03
|
show 4 more comments
When I try to log in as root (step 3 of option 2) it says -- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [1]+ Exit 1 -- is it ok?
– A. N. Other
Jul 2 '17 at 5:43
@A.N.Other edited my answer a bit
– ADDB
Jul 2 '17 at 7:20
I see only /run/mysqld/mysqld.sock in the socket list with mysql in their name...That's a bit different from the one you suggest...If you think that's ok, I'll go forward with your suggestions. Thanks.
– A. N. Other
Jul 2 '17 at 7:47
It's okay. I only said something similar.
– ADDB
Jul 2 '17 at 7:48
I put the new line with the path into the /etc/mysql/my.cnf. Then, after the "skip-grant-tables" it says: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23! mysqld: [ERROR] Fatal error in defaults handling. Program aborted! -- there is also a mysql.cnf.d dir that contains other .cnf files... mysqld.cnf mysqld_safe_syslog.cnf -- Should I edit them all?
– A. N. Other
Jul 2 '17 at 8:03
When I try to log in as root (step 3 of option 2) it says -- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [1]+ Exit 1 -- is it ok?
– A. N. Other
Jul 2 '17 at 5:43
When I try to log in as root (step 3 of option 2) it says -- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [1]+ Exit 1 -- is it ok?
– A. N. Other
Jul 2 '17 at 5:43
@A.N.Other edited my answer a bit
– ADDB
Jul 2 '17 at 7:20
@A.N.Other edited my answer a bit
– ADDB
Jul 2 '17 at 7:20
I see only /run/mysqld/mysqld.sock in the socket list with mysql in their name...That's a bit different from the one you suggest...If you think that's ok, I'll go forward with your suggestions. Thanks.
– A. N. Other
Jul 2 '17 at 7:47
I see only /run/mysqld/mysqld.sock in the socket list with mysql in their name...That's a bit different from the one you suggest...If you think that's ok, I'll go forward with your suggestions. Thanks.
– A. N. Other
Jul 2 '17 at 7:47
It's okay. I only said something similar.
– ADDB
Jul 2 '17 at 7:48
It's okay. I only said something similar.
– ADDB
Jul 2 '17 at 7:48
I put the new line with the path into the /etc/mysql/my.cnf. Then, after the "skip-grant-tables" it says: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23! mysqld: [ERROR] Fatal error in defaults handling. Program aborted! -- there is also a mysql.cnf.d dir that contains other .cnf files... mysqld.cnf mysqld_safe_syslog.cnf -- Should I edit them all?
– A. N. Other
Jul 2 '17 at 8:03
I put the new line with the path into the /etc/mysql/my.cnf. Then, after the "skip-grant-tables" it says: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23! mysqld: [ERROR] Fatal error in defaults handling. Program aborted! -- there is also a mysql.cnf.d dir that contains other .cnf files... mysqld.cnf mysqld_safe_syslog.cnf -- Should I edit them all?
– A. N. Other
Jul 2 '17 at 8:03
|
show 4 more comments
For the new my-sql 5.7 if password is left empty then it uses auth_plugin.
In that case login with sudo
privilege.
$ sudo mysql -u root -p
After login you can simply use this to update password.
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
For complete refrence check here.
EDIT:
One can also use this (without -u root
):
$ sudo mysql
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
It works also without the option-u root
he chooses automatically root. And you can leave the option-p
out. You just need to enter the sudo password, no mysql-root password
– Boba Fit
Aug 15 '18 at 21:28
add a comment |
For the new my-sql 5.7 if password is left empty then it uses auth_plugin.
In that case login with sudo
privilege.
$ sudo mysql -u root -p
After login you can simply use this to update password.
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
For complete refrence check here.
EDIT:
One can also use this (without -u root
):
$ sudo mysql
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
It works also without the option-u root
he chooses automatically root. And you can leave the option-p
out. You just need to enter the sudo password, no mysql-root password
– Boba Fit
Aug 15 '18 at 21:28
add a comment |
For the new my-sql 5.7 if password is left empty then it uses auth_plugin.
In that case login with sudo
privilege.
$ sudo mysql -u root -p
After login you can simply use this to update password.
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
For complete refrence check here.
EDIT:
One can also use this (without -u root
):
$ sudo mysql
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
For the new my-sql 5.7 if password is left empty then it uses auth_plugin.
In that case login with sudo
privilege.
$ sudo mysql -u root -p
After login you can simply use this to update password.
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
For complete refrence check here.
EDIT:
One can also use this (without -u root
):
$ sudo mysql
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
edited Aug 15 '18 at 21:54
answered Aug 15 '18 at 15:51
NandeshNandesh
1317
1317
It works also without the option-u root
he chooses automatically root. And you can leave the option-p
out. You just need to enter the sudo password, no mysql-root password
– Boba Fit
Aug 15 '18 at 21:28
add a comment |
It works also without the option-u root
he chooses automatically root. And you can leave the option-p
out. You just need to enter the sudo password, no mysql-root password
– Boba Fit
Aug 15 '18 at 21:28
It works also without the option
-u root
he chooses automatically root. And you can leave the option -p
out. You just need to enter the sudo password, no mysql-root password– Boba Fit
Aug 15 '18 at 21:28
It works also without the option
-u root
he chooses automatically root. And you can leave the option -p
out. You just need to enter the sudo password, no mysql-root password– Boba Fit
Aug 15 '18 at 21:28
add a comment |
For MySQL 5.7, the default password is printed in the logs.
A quick grep can return it.
grep 'temporary password' /var/log/mysqld.log
References:
https://www.percona.com/blog/2016/05/18/where-is-the-mysql-5-7-root-password/
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
https://stackoverflow.com/questions/33991228/what-is-the-default-root-pasword-for-mysql-5-7
https://dba.stackexchange.com/questions/127537/setting-root-password-in-fresh-mysql-5-7-installation
grep: /var/log/mysqld.log: "No such file or directory". I have /var/log/mysql and then "error.log error.log.2.gz error.log.4.gz error.log.6.gz error.log.1.gz error.log.3.gz error.log.5.gz error.log.7.gz"
– A. N. Other
Jul 1 '17 at 14:35
Try it on /var/log/mysql/error.log, then. It's just a different log name. Do any of the files around there come up with an answer? The file that you're logging to is likely somewhere in the conf file for MySQL which should be somewhere like "/etc/mysql/mysql.conf.d/mysqld.cnf"
– Bujiraso
Jul 1 '17 at 14:37
With 'temporary password' none, if i grep 'password' there is: 'Shutting down plugin 'sha256_password' and 'Shutting down plugin 'mysql_native_password', but no actual password
– A. N. Other
Jul 1 '17 at 14:42
I would do a quick "zgrep temporary *" in that dir and if that turns up nothing, follow the steps here to by-pass the access rights and set a new root password. Further detailed resetting instructions are on the MySQL docs
– Bujiraso
Jul 1 '17 at 14:46
All the info is actually distribution-dependent, and at this stage I am at a loss on what to do in my case. I wonder if anyone who wants to try mysql on Linux has to go through all of this?!?!
– A. N. Other
Jul 1 '17 at 16:01
|
show 1 more comment
For MySQL 5.7, the default password is printed in the logs.
A quick grep can return it.
grep 'temporary password' /var/log/mysqld.log
References:
https://www.percona.com/blog/2016/05/18/where-is-the-mysql-5-7-root-password/
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
https://stackoverflow.com/questions/33991228/what-is-the-default-root-pasword-for-mysql-5-7
https://dba.stackexchange.com/questions/127537/setting-root-password-in-fresh-mysql-5-7-installation
grep: /var/log/mysqld.log: "No such file or directory". I have /var/log/mysql and then "error.log error.log.2.gz error.log.4.gz error.log.6.gz error.log.1.gz error.log.3.gz error.log.5.gz error.log.7.gz"
– A. N. Other
Jul 1 '17 at 14:35
Try it on /var/log/mysql/error.log, then. It's just a different log name. Do any of the files around there come up with an answer? The file that you're logging to is likely somewhere in the conf file for MySQL which should be somewhere like "/etc/mysql/mysql.conf.d/mysqld.cnf"
– Bujiraso
Jul 1 '17 at 14:37
With 'temporary password' none, if i grep 'password' there is: 'Shutting down plugin 'sha256_password' and 'Shutting down plugin 'mysql_native_password', but no actual password
– A. N. Other
Jul 1 '17 at 14:42
I would do a quick "zgrep temporary *" in that dir and if that turns up nothing, follow the steps here to by-pass the access rights and set a new root password. Further detailed resetting instructions are on the MySQL docs
– Bujiraso
Jul 1 '17 at 14:46
All the info is actually distribution-dependent, and at this stage I am at a loss on what to do in my case. I wonder if anyone who wants to try mysql on Linux has to go through all of this?!?!
– A. N. Other
Jul 1 '17 at 16:01
|
show 1 more comment
For MySQL 5.7, the default password is printed in the logs.
A quick grep can return it.
grep 'temporary password' /var/log/mysqld.log
References:
https://www.percona.com/blog/2016/05/18/where-is-the-mysql-5-7-root-password/
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
https://stackoverflow.com/questions/33991228/what-is-the-default-root-pasword-for-mysql-5-7
https://dba.stackexchange.com/questions/127537/setting-root-password-in-fresh-mysql-5-7-installation
For MySQL 5.7, the default password is printed in the logs.
A quick grep can return it.
grep 'temporary password' /var/log/mysqld.log
References:
https://www.percona.com/blog/2016/05/18/where-is-the-mysql-5-7-root-password/
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
https://stackoverflow.com/questions/33991228/what-is-the-default-root-pasword-for-mysql-5-7
https://dba.stackexchange.com/questions/127537/setting-root-password-in-fresh-mysql-5-7-installation
edited Jul 1 '17 at 14:41
answered Jul 1 '17 at 14:30
BujirasoBujiraso
1864
1864
grep: /var/log/mysqld.log: "No such file or directory". I have /var/log/mysql and then "error.log error.log.2.gz error.log.4.gz error.log.6.gz error.log.1.gz error.log.3.gz error.log.5.gz error.log.7.gz"
– A. N. Other
Jul 1 '17 at 14:35
Try it on /var/log/mysql/error.log, then. It's just a different log name. Do any of the files around there come up with an answer? The file that you're logging to is likely somewhere in the conf file for MySQL which should be somewhere like "/etc/mysql/mysql.conf.d/mysqld.cnf"
– Bujiraso
Jul 1 '17 at 14:37
With 'temporary password' none, if i grep 'password' there is: 'Shutting down plugin 'sha256_password' and 'Shutting down plugin 'mysql_native_password', but no actual password
– A. N. Other
Jul 1 '17 at 14:42
I would do a quick "zgrep temporary *" in that dir and if that turns up nothing, follow the steps here to by-pass the access rights and set a new root password. Further detailed resetting instructions are on the MySQL docs
– Bujiraso
Jul 1 '17 at 14:46
All the info is actually distribution-dependent, and at this stage I am at a loss on what to do in my case. I wonder if anyone who wants to try mysql on Linux has to go through all of this?!?!
– A. N. Other
Jul 1 '17 at 16:01
|
show 1 more comment
grep: /var/log/mysqld.log: "No such file or directory". I have /var/log/mysql and then "error.log error.log.2.gz error.log.4.gz error.log.6.gz error.log.1.gz error.log.3.gz error.log.5.gz error.log.7.gz"
– A. N. Other
Jul 1 '17 at 14:35
Try it on /var/log/mysql/error.log, then. It's just a different log name. Do any of the files around there come up with an answer? The file that you're logging to is likely somewhere in the conf file for MySQL which should be somewhere like "/etc/mysql/mysql.conf.d/mysqld.cnf"
– Bujiraso
Jul 1 '17 at 14:37
With 'temporary password' none, if i grep 'password' there is: 'Shutting down plugin 'sha256_password' and 'Shutting down plugin 'mysql_native_password', but no actual password
– A. N. Other
Jul 1 '17 at 14:42
I would do a quick "zgrep temporary *" in that dir and if that turns up nothing, follow the steps here to by-pass the access rights and set a new root password. Further detailed resetting instructions are on the MySQL docs
– Bujiraso
Jul 1 '17 at 14:46
All the info is actually distribution-dependent, and at this stage I am at a loss on what to do in my case. I wonder if anyone who wants to try mysql on Linux has to go through all of this?!?!
– A. N. Other
Jul 1 '17 at 16:01
grep: /var/log/mysqld.log: "No such file or directory". I have /var/log/mysql and then "error.log error.log.2.gz error.log.4.gz error.log.6.gz error.log.1.gz error.log.3.gz error.log.5.gz error.log.7.gz"
– A. N. Other
Jul 1 '17 at 14:35
grep: /var/log/mysqld.log: "No such file or directory". I have /var/log/mysql and then "error.log error.log.2.gz error.log.4.gz error.log.6.gz error.log.1.gz error.log.3.gz error.log.5.gz error.log.7.gz"
– A. N. Other
Jul 1 '17 at 14:35
Try it on /var/log/mysql/error.log, then. It's just a different log name. Do any of the files around there come up with an answer? The file that you're logging to is likely somewhere in the conf file for MySQL which should be somewhere like "/etc/mysql/mysql.conf.d/mysqld.cnf"
– Bujiraso
Jul 1 '17 at 14:37
Try it on /var/log/mysql/error.log, then. It's just a different log name. Do any of the files around there come up with an answer? The file that you're logging to is likely somewhere in the conf file for MySQL which should be somewhere like "/etc/mysql/mysql.conf.d/mysqld.cnf"
– Bujiraso
Jul 1 '17 at 14:37
With 'temporary password' none, if i grep 'password' there is: 'Shutting down plugin 'sha256_password' and 'Shutting down plugin 'mysql_native_password', but no actual password
– A. N. Other
Jul 1 '17 at 14:42
With 'temporary password' none, if i grep 'password' there is: 'Shutting down plugin 'sha256_password' and 'Shutting down plugin 'mysql_native_password', but no actual password
– A. N. Other
Jul 1 '17 at 14:42
I would do a quick "zgrep temporary *" in that dir and if that turns up nothing, follow the steps here to by-pass the access rights and set a new root password. Further detailed resetting instructions are on the MySQL docs
– Bujiraso
Jul 1 '17 at 14:46
I would do a quick "zgrep temporary *" in that dir and if that turns up nothing, follow the steps here to by-pass the access rights and set a new root password. Further detailed resetting instructions are on the MySQL docs
– Bujiraso
Jul 1 '17 at 14:46
All the info is actually distribution-dependent, and at this stage I am at a loss on what to do in my case. I wonder if anyone who wants to try mysql on Linux has to go through all of this?!?!
– A. N. Other
Jul 1 '17 at 16:01
All the info is actually distribution-dependent, and at this stage I am at a loss on what to do in my case. I wonder if anyone who wants to try mysql on Linux has to go through all of this?!?!
– A. N. Other
Jul 1 '17 at 16:01
|
show 1 more comment
UBUNTU 16.04 and MYSQL 5.7.20
I did not find ADDB's instructions completely helpful. After searching I discovered the following (a small re-write for Option 2):
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set authentication_string=PASSWORD("NEW_PASSWORD_GOES_HERE") where User='root';
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Reference: http://rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts/
My preferred method:
I used the Mysql user "debian-sys-maint" (a root equivelant). The password can be found in /etc/mysql/debian.cnf. After logging into Mysql as this user change the password for any Mysql user.
USE mysql
SELECT root@localhost;
ALTER USER user IDENTIFIED BY 'auth_string';
ALTER USER 'Name_of_user_to_be_modified'@'Hostname (ie:localhost)' IDENTIFIED BY 'NEW_PASSWORD';
flush privileges;
exit;
Reference:
https://serverfault.com/questions/9948/what-is-the-debian-sys-maint-mysql-user-and-more
add a comment |
UBUNTU 16.04 and MYSQL 5.7.20
I did not find ADDB's instructions completely helpful. After searching I discovered the following (a small re-write for Option 2):
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set authentication_string=PASSWORD("NEW_PASSWORD_GOES_HERE") where User='root';
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Reference: http://rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts/
My preferred method:
I used the Mysql user "debian-sys-maint" (a root equivelant). The password can be found in /etc/mysql/debian.cnf. After logging into Mysql as this user change the password for any Mysql user.
USE mysql
SELECT root@localhost;
ALTER USER user IDENTIFIED BY 'auth_string';
ALTER USER 'Name_of_user_to_be_modified'@'Hostname (ie:localhost)' IDENTIFIED BY 'NEW_PASSWORD';
flush privileges;
exit;
Reference:
https://serverfault.com/questions/9948/what-is-the-debian-sys-maint-mysql-user-and-more
add a comment |
UBUNTU 16.04 and MYSQL 5.7.20
I did not find ADDB's instructions completely helpful. After searching I discovered the following (a small re-write for Option 2):
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set authentication_string=PASSWORD("NEW_PASSWORD_GOES_HERE") where User='root';
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Reference: http://rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts/
My preferred method:
I used the Mysql user "debian-sys-maint" (a root equivelant). The password can be found in /etc/mysql/debian.cnf. After logging into Mysql as this user change the password for any Mysql user.
USE mysql
SELECT root@localhost;
ALTER USER user IDENTIFIED BY 'auth_string';
ALTER USER 'Name_of_user_to_be_modified'@'Hostname (ie:localhost)' IDENTIFIED BY 'NEW_PASSWORD';
flush privileges;
exit;
Reference:
https://serverfault.com/questions/9948/what-is-the-debian-sys-maint-mysql-user-and-more
UBUNTU 16.04 and MYSQL 5.7.20
I did not find ADDB's instructions completely helpful. After searching I discovered the following (a small re-write for Option 2):
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set authentication_string=PASSWORD("NEW_PASSWORD_GOES_HERE") where User='root';
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Reference: http://rricketts.com/reset-root-password-mysql-5-7-ubuntu-16-04-lts/
My preferred method:
I used the Mysql user "debian-sys-maint" (a root equivelant). The password can be found in /etc/mysql/debian.cnf. After logging into Mysql as this user change the password for any Mysql user.
USE mysql
SELECT root@localhost;
ALTER USER user IDENTIFIED BY 'auth_string';
ALTER USER 'Name_of_user_to_be_modified'@'Hostname (ie:localhost)' IDENTIFIED BY 'NEW_PASSWORD';
flush privileges;
exit;
Reference:
https://serverfault.com/questions/9948/what-is-the-debian-sys-maint-mysql-user-and-more
answered Nov 12 '17 at 17:02
arthurjohnstonarthurjohnston
65
65
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f931001%2fproblem-with-mysql-root-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
this link has all in it-> dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
– Akhil Varma
Jul 1 '17 at 17:27