Ubuntu 18.04 LTS after fresh install of MySQL / PHPMyadmin; no root password; unable to login with PHPmyadmin
After a fresh install of Ubuntu 18.04 LTS Bionic Beaver and setting up a LAMP stack as well as installing PHPMyadmin I am unable to login to PHPMyadmin as the password I have give while securing mysql with mysql_secure_installation is not correct, so its seems.
I search the internet for solutions, but all solutions provided have no positive result in my case.
A working solution will be appreciated.
apache2 mysql lamp phpmyadmin
add a comment |
After a fresh install of Ubuntu 18.04 LTS Bionic Beaver and setting up a LAMP stack as well as installing PHPMyadmin I am unable to login to PHPMyadmin as the password I have give while securing mysql with mysql_secure_installation is not correct, so its seems.
I search the internet for solutions, but all solutions provided have no positive result in my case.
A working solution will be appreciated.
apache2 mysql lamp phpmyadmin
add a comment |
After a fresh install of Ubuntu 18.04 LTS Bionic Beaver and setting up a LAMP stack as well as installing PHPMyadmin I am unable to login to PHPMyadmin as the password I have give while securing mysql with mysql_secure_installation is not correct, so its seems.
I search the internet for solutions, but all solutions provided have no positive result in my case.
A working solution will be appreciated.
apache2 mysql lamp phpmyadmin
After a fresh install of Ubuntu 18.04 LTS Bionic Beaver and setting up a LAMP stack as well as installing PHPMyadmin I am unable to login to PHPMyadmin as the password I have give while securing mysql with mysql_secure_installation is not correct, so its seems.
I search the internet for solutions, but all solutions provided have no positive result in my case.
A working solution will be appreciated.
apache2 mysql lamp phpmyadmin
apache2 mysql lamp phpmyadmin
asked May 2 '18 at 17:35
BridgeBridge
1612
1612
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
I had the same problem. Apparently MySQL was set up by default to use socket-based authentication, which uses the system username, and not a password. To fix the problem, I used the following commands:
Access MySQL as the root user:
sudo mysql # or sudo mysql -u root
Set the password for the MySQL root user:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
Replace 'test' above with the actual password you want to use
After looking for this everywhere and following a lot of guides, this worked for me. Thanks a lot @heyjoe
– Encrypter
Jul 8 '18 at 7:22
FYI the "alter user" string above enabled me to force password authentication for an out of the box Ubuntu 18.04 setup with MySQL. Previously it was letting me in without enforcing password authentication (would accept any password put in by the root user). Thanks for the help @heyjoe ! :D
– BloodyIron
Nov 11 '18 at 21:25
add a comment |
The solution is to switch authentication method of MySQL from socket authentication ( i.e. auth_socket
) to password authentication (i.e. mysql_native_password
plugin).
MySQL 5.7 and later versions uses the socket authentication by default. It means you could start MySQL by sudo mysql
in the terminal without a password. Even if you create a new root password using mysql_secure_installation
, you would not be able to access third party softwares like phpmyadmin which uses password authentication. Following is the solution:
sudo apt install mysql-server
sudo mysql_secure_installation
After entering mysql_secure_installation
create a password for root, and click YES for the rest of questions.
[You can notice that still MySQL is starting without any password because the default authentication method has not been changed till now ! ]
Now, enter MySQL
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
Now you can see in the following output, that root has plugin asauth_socket
instead of mysql_native_password
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | | auth_socket | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
Now we have to change the plugin to mysql_native_password
. Replace the 'password' in the following command with a strong password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
Now you can check the auth methods for each user, using the same above command
SELECT user,authentication_string,plugin,host FROM mysql.user;
Output:
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *C035F91799F4415B005D146ECEB5ADD4D991031F | mysql_native_password | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
If your output is like the above, with plugin for root as mysql_native_password
, you are good to go :) Now you can simply access phpmyadmin with the root and its password. Hope this helps.
This link helped me to understand this concept much better
add a comment |
I had to log in with
mysql -u root -p
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%2f1031198%2fubuntu-18-04-lts-after-fresh-install-of-mysql-phpmyadmin-no-root-password-un%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had the same problem. Apparently MySQL was set up by default to use socket-based authentication, which uses the system username, and not a password. To fix the problem, I used the following commands:
Access MySQL as the root user:
sudo mysql # or sudo mysql -u root
Set the password for the MySQL root user:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
Replace 'test' above with the actual password you want to use
After looking for this everywhere and following a lot of guides, this worked for me. Thanks a lot @heyjoe
– Encrypter
Jul 8 '18 at 7:22
FYI the "alter user" string above enabled me to force password authentication for an out of the box Ubuntu 18.04 setup with MySQL. Previously it was letting me in without enforcing password authentication (would accept any password put in by the root user). Thanks for the help @heyjoe ! :D
– BloodyIron
Nov 11 '18 at 21:25
add a comment |
I had the same problem. Apparently MySQL was set up by default to use socket-based authentication, which uses the system username, and not a password. To fix the problem, I used the following commands:
Access MySQL as the root user:
sudo mysql # or sudo mysql -u root
Set the password for the MySQL root user:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
Replace 'test' above with the actual password you want to use
After looking for this everywhere and following a lot of guides, this worked for me. Thanks a lot @heyjoe
– Encrypter
Jul 8 '18 at 7:22
FYI the "alter user" string above enabled me to force password authentication for an out of the box Ubuntu 18.04 setup with MySQL. Previously it was letting me in without enforcing password authentication (would accept any password put in by the root user). Thanks for the help @heyjoe ! :D
– BloodyIron
Nov 11 '18 at 21:25
add a comment |
I had the same problem. Apparently MySQL was set up by default to use socket-based authentication, which uses the system username, and not a password. To fix the problem, I used the following commands:
Access MySQL as the root user:
sudo mysql # or sudo mysql -u root
Set the password for the MySQL root user:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
Replace 'test' above with the actual password you want to use
I had the same problem. Apparently MySQL was set up by default to use socket-based authentication, which uses the system username, and not a password. To fix the problem, I used the following commands:
Access MySQL as the root user:
sudo mysql # or sudo mysql -u root
Set the password for the MySQL root user:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
Replace 'test' above with the actual password you want to use
answered May 18 '18 at 18:26
heyjoeheyjoe
811
811
After looking for this everywhere and following a lot of guides, this worked for me. Thanks a lot @heyjoe
– Encrypter
Jul 8 '18 at 7:22
FYI the "alter user" string above enabled me to force password authentication for an out of the box Ubuntu 18.04 setup with MySQL. Previously it was letting me in without enforcing password authentication (would accept any password put in by the root user). Thanks for the help @heyjoe ! :D
– BloodyIron
Nov 11 '18 at 21:25
add a comment |
After looking for this everywhere and following a lot of guides, this worked for me. Thanks a lot @heyjoe
– Encrypter
Jul 8 '18 at 7:22
FYI the "alter user" string above enabled me to force password authentication for an out of the box Ubuntu 18.04 setup with MySQL. Previously it was letting me in without enforcing password authentication (would accept any password put in by the root user). Thanks for the help @heyjoe ! :D
– BloodyIron
Nov 11 '18 at 21:25
After looking for this everywhere and following a lot of guides, this worked for me. Thanks a lot @heyjoe
– Encrypter
Jul 8 '18 at 7:22
After looking for this everywhere and following a lot of guides, this worked for me. Thanks a lot @heyjoe
– Encrypter
Jul 8 '18 at 7:22
FYI the "alter user" string above enabled me to force password authentication for an out of the box Ubuntu 18.04 setup with MySQL. Previously it was letting me in without enforcing password authentication (would accept any password put in by the root user). Thanks for the help @heyjoe ! :D
– BloodyIron
Nov 11 '18 at 21:25
FYI the "alter user" string above enabled me to force password authentication for an out of the box Ubuntu 18.04 setup with MySQL. Previously it was letting me in without enforcing password authentication (would accept any password put in by the root user). Thanks for the help @heyjoe ! :D
– BloodyIron
Nov 11 '18 at 21:25
add a comment |
The solution is to switch authentication method of MySQL from socket authentication ( i.e. auth_socket
) to password authentication (i.e. mysql_native_password
plugin).
MySQL 5.7 and later versions uses the socket authentication by default. It means you could start MySQL by sudo mysql
in the terminal without a password. Even if you create a new root password using mysql_secure_installation
, you would not be able to access third party softwares like phpmyadmin which uses password authentication. Following is the solution:
sudo apt install mysql-server
sudo mysql_secure_installation
After entering mysql_secure_installation
create a password for root, and click YES for the rest of questions.
[You can notice that still MySQL is starting without any password because the default authentication method has not been changed till now ! ]
Now, enter MySQL
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
Now you can see in the following output, that root has plugin asauth_socket
instead of mysql_native_password
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | | auth_socket | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
Now we have to change the plugin to mysql_native_password
. Replace the 'password' in the following command with a strong password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
Now you can check the auth methods for each user, using the same above command
SELECT user,authentication_string,plugin,host FROM mysql.user;
Output:
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *C035F91799F4415B005D146ECEB5ADD4D991031F | mysql_native_password | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
If your output is like the above, with plugin for root as mysql_native_password
, you are good to go :) Now you can simply access phpmyadmin with the root and its password. Hope this helps.
This link helped me to understand this concept much better
add a comment |
The solution is to switch authentication method of MySQL from socket authentication ( i.e. auth_socket
) to password authentication (i.e. mysql_native_password
plugin).
MySQL 5.7 and later versions uses the socket authentication by default. It means you could start MySQL by sudo mysql
in the terminal without a password. Even if you create a new root password using mysql_secure_installation
, you would not be able to access third party softwares like phpmyadmin which uses password authentication. Following is the solution:
sudo apt install mysql-server
sudo mysql_secure_installation
After entering mysql_secure_installation
create a password for root, and click YES for the rest of questions.
[You can notice that still MySQL is starting without any password because the default authentication method has not been changed till now ! ]
Now, enter MySQL
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
Now you can see in the following output, that root has plugin asauth_socket
instead of mysql_native_password
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | | auth_socket | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
Now we have to change the plugin to mysql_native_password
. Replace the 'password' in the following command with a strong password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
Now you can check the auth methods for each user, using the same above command
SELECT user,authentication_string,plugin,host FROM mysql.user;
Output:
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *C035F91799F4415B005D146ECEB5ADD4D991031F | mysql_native_password | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
If your output is like the above, with plugin for root as mysql_native_password
, you are good to go :) Now you can simply access phpmyadmin with the root and its password. Hope this helps.
This link helped me to understand this concept much better
add a comment |
The solution is to switch authentication method of MySQL from socket authentication ( i.e. auth_socket
) to password authentication (i.e. mysql_native_password
plugin).
MySQL 5.7 and later versions uses the socket authentication by default. It means you could start MySQL by sudo mysql
in the terminal without a password. Even if you create a new root password using mysql_secure_installation
, you would not be able to access third party softwares like phpmyadmin which uses password authentication. Following is the solution:
sudo apt install mysql-server
sudo mysql_secure_installation
After entering mysql_secure_installation
create a password for root, and click YES for the rest of questions.
[You can notice that still MySQL is starting without any password because the default authentication method has not been changed till now ! ]
Now, enter MySQL
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
Now you can see in the following output, that root has plugin asauth_socket
instead of mysql_native_password
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | | auth_socket | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
Now we have to change the plugin to mysql_native_password
. Replace the 'password' in the following command with a strong password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
Now you can check the auth methods for each user, using the same above command
SELECT user,authentication_string,plugin,host FROM mysql.user;
Output:
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *C035F91799F4415B005D146ECEB5ADD4D991031F | mysql_native_password | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
If your output is like the above, with plugin for root as mysql_native_password
, you are good to go :) Now you can simply access phpmyadmin with the root and its password. Hope this helps.
This link helped me to understand this concept much better
The solution is to switch authentication method of MySQL from socket authentication ( i.e. auth_socket
) to password authentication (i.e. mysql_native_password
plugin).
MySQL 5.7 and later versions uses the socket authentication by default. It means you could start MySQL by sudo mysql
in the terminal without a password. Even if you create a new root password using mysql_secure_installation
, you would not be able to access third party softwares like phpmyadmin which uses password authentication. Following is the solution:
sudo apt install mysql-server
sudo mysql_secure_installation
After entering mysql_secure_installation
create a password for root, and click YES for the rest of questions.
[You can notice that still MySQL is starting without any password because the default authentication method has not been changed till now ! ]
Now, enter MySQL
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
Now you can see in the following output, that root has plugin asauth_socket
instead of mysql_native_password
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | | auth_socket | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
Now we have to change the plugin to mysql_native_password
. Replace the 'password' in the following command with a strong password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
Now you can check the auth methods for each user, using the same above command
SELECT user,authentication_string,plugin,host FROM mysql.user;
Output:
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *C035F91799F4415B005D146ECEB5ADD4D991031F | mysql_native_password | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *832A85D6EC83FA4A19ACFD461F672B95E4540611 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
If your output is like the above, with plugin for root as mysql_native_password
, you are good to go :) Now you can simply access phpmyadmin with the root and its password. Hope this helps.
This link helped me to understand this concept much better
answered Feb 5 at 19:49
Swapnil SourabhSwapnil Sourabh
111
111
add a comment |
add a comment |
I had to log in with
mysql -u root -p
add a comment |
I had to log in with
mysql -u root -p
add a comment |
I had to log in with
mysql -u root -p
I had to log in with
mysql -u root -p
answered Jul 1 '18 at 19:29
CancelorCancelor
1
1
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%2f1031198%2fubuntu-18-04-lts-after-fresh-install-of-mysql-phpmyadmin-no-root-password-un%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