mysql doesn't ask for root password when installing
up vote
39
down vote
favorite
I used apt install mysql-server
to install MySQL on Ubuntu 16.04 but during the installation, it did not ask for root password.
After installation I got ERROR 1045
when I tried to login as root
and mysql_secure_installation
threw the same error. I purge
d and autoremove
d then reinstalled but it does not work.
How could i fix this? Can I set the root password if I didn't set it during installation?
This is my installation log:
The following additional packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server-5.7
mysql-server-core-5.7
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server mysql-server-5.7
mysql-server-core-5.7
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/17,9 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package libaio1:amd64.
(Reading database ... 227144 files and directories currently installed.)
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-5.7.
Preparing to unpack .../mysql-server-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libaio1:amd64 (0.3.110-2) ...
Setting up mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-client-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
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
Setting up mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
software-installation password mysql root
add a comment |
up vote
39
down vote
favorite
I used apt install mysql-server
to install MySQL on Ubuntu 16.04 but during the installation, it did not ask for root password.
After installation I got ERROR 1045
when I tried to login as root
and mysql_secure_installation
threw the same error. I purge
d and autoremove
d then reinstalled but it does not work.
How could i fix this? Can I set the root password if I didn't set it during installation?
This is my installation log:
The following additional packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server-5.7
mysql-server-core-5.7
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server mysql-server-5.7
mysql-server-core-5.7
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/17,9 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package libaio1:amd64.
(Reading database ... 227144 files and directories currently installed.)
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-5.7.
Preparing to unpack .../mysql-server-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libaio1:amd64 (0.3.110-2) ...
Setting up mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-client-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
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
Setting up mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
software-installation password mysql root
add a comment |
up vote
39
down vote
favorite
up vote
39
down vote
favorite
I used apt install mysql-server
to install MySQL on Ubuntu 16.04 but during the installation, it did not ask for root password.
After installation I got ERROR 1045
when I tried to login as root
and mysql_secure_installation
threw the same error. I purge
d and autoremove
d then reinstalled but it does not work.
How could i fix this? Can I set the root password if I didn't set it during installation?
This is my installation log:
The following additional packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server-5.7
mysql-server-core-5.7
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server mysql-server-5.7
mysql-server-core-5.7
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/17,9 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package libaio1:amd64.
(Reading database ... 227144 files and directories currently installed.)
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-5.7.
Preparing to unpack .../mysql-server-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libaio1:amd64 (0.3.110-2) ...
Setting up mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-client-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
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
Setting up mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
software-installation password mysql root
I used apt install mysql-server
to install MySQL on Ubuntu 16.04 but during the installation, it did not ask for root password.
After installation I got ERROR 1045
when I tried to login as root
and mysql_secure_installation
threw the same error. I purge
d and autoremove
d then reinstalled but it does not work.
How could i fix this? Can I set the root password if I didn't set it during installation?
This is my installation log:
The following additional packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server-5.7
mysql-server-core-5.7
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-server mysql-server-5.7
mysql-server-core-5.7
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/17,9 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package libaio1:amd64.
(Reading database ... 227144 files and directories currently installed.)
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server-5.7.
Preparing to unpack .../mysql-server-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libaio1:amd64 (0.3.110-2) ...
Setting up mysql-client-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-client-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-core-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
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
Setting up mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
software-installation password mysql root
software-installation password mysql root
edited Jan 5 '17 at 11:53
Zanna
49.1k13123234
49.1k13123234
asked May 3 '16 at 14:04
spqa
308137
308137
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
up vote
41
down vote
accepted
You can recover or set root password without knowing the current one by starting mysql without loading the grant-tables.
Please note the $
in the commands. This is specifying the terminal prompt you see when typing in the command. It's showing it's a line of text, but and actual typed terminal command. The "mysql>
" prefix is also a prompt. That is the prompt you get when running mysql interactivately.
This is the cli (command line) to do this:
(Be sure to stop the current server before performing the steps. Only one server can run at a time.)
$ sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld
$ sudo mysqld_safe --skip-grant-tables&
Now you can log in as root without a password and perform all commands, as in this case, set the root password as root.
$ sudo mysql --user=root mysql
This is the set root password that you will perform inside mysql if you have MySQL 5.6 or below:
mysql> update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
In MySQL 5.7 or above
mysql> update user set authentication_string=PASSWORD('new-password') where user='root';
flush privileges;
From there, quit (kill the running msqld) mysql and start it as normal.
Notes on starting and stopping the mysql service:
Stop mysql:
$ sudo service mysql stop
Start mysql (normal):
$ sudo service mysql start
Kill the temporary mysql safe mode session:
$ sudo mysqladmin shutdown
8
in mysql 5.7.12 there is no column named password in user table. Hence following command worked for me. update user set authentication_string=PASSWORD('new-password') where user='root';
– The Code
Jun 20 '16 at 19:05
6
I'm still gettingERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr
Jul 18 '16 at 16:51
@ErelSegal-Halevi There are two things you should do. Run$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh .
– L. D. James
Aug 4 '16 at 13:16
add a comment |
up vote
24
down vote
It will not ask for the password while installing mysql
in Ubuntu 16.04 but you can set it after successful installation in following way:
After completion of mysql installation, run command:
sudo mysql_secure_installation
It will show:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and you
haven't set the root password yet, the password will be blank, so you
should just press enter here.
Enter current password for root (enter for none):
(here press Enter)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y (press 'y' to set new password)
New password:
Re-enter new password:
Password updated successfully! Reloading privilege tables.. ...
Success!
FOR UBUNTU 18.04 OR mysql-server
version 5.7.22, THIS METHOD WILL NOT WORK
Follow these steps to set root password in 18.04:
As there is no password set for root user, simply login with blank password
sudo mysql -u root -p
Enter password: (press enter as no password is set)
after then can easily run query
ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
2
The problem in the case of this question is that the user can't get to the prompts you're mentioned because he doesn't know thecurrent password for root
.
– L. D. James
May 4 '16 at 5:12
@L.D.James yes,you're right. I don't remember about ERROR : 1405 when i runmysql_secure_installation
butsudo mysql_secure_installation
worked for me. mysql installation doesn't ask for password. It happened with me the same. andhere press enter
means press enter without password.
– d a i s y
May 4 '16 at 5:35
1
As concers ubuntu 18.04 or debian 9+ it won't connect with blank password and even after resetting pass for root, it still refuses to connect
– chefarov
Oct 11 at 18:04
add a comment |
up vote
14
down vote
Apparently the mysql-server installation on 16.04 (or any 5.7 installation?) allows root access not through password, but through the auth_socket plugin. Running sudo mysql -u root
(n.b. w/o a password) will give you mysql console whereas running the command as non-root prompts you for a password.
It would seem that changing the password doesn't make much of a difference since the auth backend doesn't even check for a password. There is a very comprehensive article on how to change the plugin and switch to password authentication.
3
I was able to confirm with a fresh installation ofapt install mysql-server
without specifying a password on 18.04. The symptom and solution is exactly as described.
– EricC
Jun 18 at 2:45
add a comment |
up vote
0
down vote
Adding to the main answer, If you are stuck at
"mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql"
1 thing to remember that you have to use another terminal window to enter the following command.
$ sudo mysql --user=root mysql
If you try to do it in the same window, it will shut down the mysqld safemode process.
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
41
down vote
accepted
You can recover or set root password without knowing the current one by starting mysql without loading the grant-tables.
Please note the $
in the commands. This is specifying the terminal prompt you see when typing in the command. It's showing it's a line of text, but and actual typed terminal command. The "mysql>
" prefix is also a prompt. That is the prompt you get when running mysql interactivately.
This is the cli (command line) to do this:
(Be sure to stop the current server before performing the steps. Only one server can run at a time.)
$ sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld
$ sudo mysqld_safe --skip-grant-tables&
Now you can log in as root without a password and perform all commands, as in this case, set the root password as root.
$ sudo mysql --user=root mysql
This is the set root password that you will perform inside mysql if you have MySQL 5.6 or below:
mysql> update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
In MySQL 5.7 or above
mysql> update user set authentication_string=PASSWORD('new-password') where user='root';
flush privileges;
From there, quit (kill the running msqld) mysql and start it as normal.
Notes on starting and stopping the mysql service:
Stop mysql:
$ sudo service mysql stop
Start mysql (normal):
$ sudo service mysql start
Kill the temporary mysql safe mode session:
$ sudo mysqladmin shutdown
8
in mysql 5.7.12 there is no column named password in user table. Hence following command worked for me. update user set authentication_string=PASSWORD('new-password') where user='root';
– The Code
Jun 20 '16 at 19:05
6
I'm still gettingERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr
Jul 18 '16 at 16:51
@ErelSegal-Halevi There are two things you should do. Run$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh .
– L. D. James
Aug 4 '16 at 13:16
add a comment |
up vote
41
down vote
accepted
You can recover or set root password without knowing the current one by starting mysql without loading the grant-tables.
Please note the $
in the commands. This is specifying the terminal prompt you see when typing in the command. It's showing it's a line of text, but and actual typed terminal command. The "mysql>
" prefix is also a prompt. That is the prompt you get when running mysql interactivately.
This is the cli (command line) to do this:
(Be sure to stop the current server before performing the steps. Only one server can run at a time.)
$ sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld
$ sudo mysqld_safe --skip-grant-tables&
Now you can log in as root without a password and perform all commands, as in this case, set the root password as root.
$ sudo mysql --user=root mysql
This is the set root password that you will perform inside mysql if you have MySQL 5.6 or below:
mysql> update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
In MySQL 5.7 or above
mysql> update user set authentication_string=PASSWORD('new-password') where user='root';
flush privileges;
From there, quit (kill the running msqld) mysql and start it as normal.
Notes on starting and stopping the mysql service:
Stop mysql:
$ sudo service mysql stop
Start mysql (normal):
$ sudo service mysql start
Kill the temporary mysql safe mode session:
$ sudo mysqladmin shutdown
8
in mysql 5.7.12 there is no column named password in user table. Hence following command worked for me. update user set authentication_string=PASSWORD('new-password') where user='root';
– The Code
Jun 20 '16 at 19:05
6
I'm still gettingERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr
Jul 18 '16 at 16:51
@ErelSegal-Halevi There are two things you should do. Run$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh .
– L. D. James
Aug 4 '16 at 13:16
add a comment |
up vote
41
down vote
accepted
up vote
41
down vote
accepted
You can recover or set root password without knowing the current one by starting mysql without loading the grant-tables.
Please note the $
in the commands. This is specifying the terminal prompt you see when typing in the command. It's showing it's a line of text, but and actual typed terminal command. The "mysql>
" prefix is also a prompt. That is the prompt you get when running mysql interactivately.
This is the cli (command line) to do this:
(Be sure to stop the current server before performing the steps. Only one server can run at a time.)
$ sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld
$ sudo mysqld_safe --skip-grant-tables&
Now you can log in as root without a password and perform all commands, as in this case, set the root password as root.
$ sudo mysql --user=root mysql
This is the set root password that you will perform inside mysql if you have MySQL 5.6 or below:
mysql> update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
In MySQL 5.7 or above
mysql> update user set authentication_string=PASSWORD('new-password') where user='root';
flush privileges;
From there, quit (kill the running msqld) mysql and start it as normal.
Notes on starting and stopping the mysql service:
Stop mysql:
$ sudo service mysql stop
Start mysql (normal):
$ sudo service mysql start
Kill the temporary mysql safe mode session:
$ sudo mysqladmin shutdown
You can recover or set root password without knowing the current one by starting mysql without loading the grant-tables.
Please note the $
in the commands. This is specifying the terminal prompt you see when typing in the command. It's showing it's a line of text, but and actual typed terminal command. The "mysql>
" prefix is also a prompt. That is the prompt you get when running mysql interactivately.
This is the cli (command line) to do this:
(Be sure to stop the current server before performing the steps. Only one server can run at a time.)
$ sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld
$ sudo mysqld_safe --skip-grant-tables&
Now you can log in as root without a password and perform all commands, as in this case, set the root password as root.
$ sudo mysql --user=root mysql
This is the set root password that you will perform inside mysql if you have MySQL 5.6 or below:
mysql> update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
In MySQL 5.7 or above
mysql> update user set authentication_string=PASSWORD('new-password') where user='root';
flush privileges;
From there, quit (kill the running msqld) mysql and start it as normal.
Notes on starting and stopping the mysql service:
Stop mysql:
$ sudo service mysql stop
Start mysql (normal):
$ sudo service mysql start
Kill the temporary mysql safe mode session:
$ sudo mysqladmin shutdown
edited Mar 13 '17 at 14:07
answered May 3 '16 at 14:27
L. D. James
17.9k43482
17.9k43482
8
in mysql 5.7.12 there is no column named password in user table. Hence following command worked for me. update user set authentication_string=PASSWORD('new-password') where user='root';
– The Code
Jun 20 '16 at 19:05
6
I'm still gettingERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr
Jul 18 '16 at 16:51
@ErelSegal-Halevi There are two things you should do. Run$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh .
– L. D. James
Aug 4 '16 at 13:16
add a comment |
8
in mysql 5.7.12 there is no column named password in user table. Hence following command worked for me. update user set authentication_string=PASSWORD('new-password') where user='root';
– The Code
Jun 20 '16 at 19:05
6
I'm still gettingERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr
Jul 18 '16 at 16:51
@ErelSegal-Halevi There are two things you should do. Run$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh .
– L. D. James
Aug 4 '16 at 13:16
8
8
in mysql 5.7.12 there is no column named password in user table. Hence following command worked for me. update user set authentication_string=PASSWORD('new-password') where user='root';
– The Code
Jun 20 '16 at 19:05
in mysql 5.7.12 there is no column named password in user table. Hence following command worked for me. update user set authentication_string=PASSWORD('new-password') where user='root';
– The Code
Jun 20 '16 at 19:05
6
6
I'm still getting
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr
Jul 18 '16 at 16:51
I'm still getting
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr
Jul 18 '16 at 16:51
@ErelSegal-Halevi There are two things you should do. Run
$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh .– L. D. James
Aug 4 '16 at 13:16
@ErelSegal-Halevi There are two things you should do. Run
$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh .– L. D. James
Aug 4 '16 at 13:16
add a comment |
up vote
24
down vote
It will not ask for the password while installing mysql
in Ubuntu 16.04 but you can set it after successful installation in following way:
After completion of mysql installation, run command:
sudo mysql_secure_installation
It will show:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and you
haven't set the root password yet, the password will be blank, so you
should just press enter here.
Enter current password for root (enter for none):
(here press Enter)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y (press 'y' to set new password)
New password:
Re-enter new password:
Password updated successfully! Reloading privilege tables.. ...
Success!
FOR UBUNTU 18.04 OR mysql-server
version 5.7.22, THIS METHOD WILL NOT WORK
Follow these steps to set root password in 18.04:
As there is no password set for root user, simply login with blank password
sudo mysql -u root -p
Enter password: (press enter as no password is set)
after then can easily run query
ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
2
The problem in the case of this question is that the user can't get to the prompts you're mentioned because he doesn't know thecurrent password for root
.
– L. D. James
May 4 '16 at 5:12
@L.D.James yes,you're right. I don't remember about ERROR : 1405 when i runmysql_secure_installation
butsudo mysql_secure_installation
worked for me. mysql installation doesn't ask for password. It happened with me the same. andhere press enter
means press enter without password.
– d a i s y
May 4 '16 at 5:35
1
As concers ubuntu 18.04 or debian 9+ it won't connect with blank password and even after resetting pass for root, it still refuses to connect
– chefarov
Oct 11 at 18:04
add a comment |
up vote
24
down vote
It will not ask for the password while installing mysql
in Ubuntu 16.04 but you can set it after successful installation in following way:
After completion of mysql installation, run command:
sudo mysql_secure_installation
It will show:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and you
haven't set the root password yet, the password will be blank, so you
should just press enter here.
Enter current password for root (enter for none):
(here press Enter)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y (press 'y' to set new password)
New password:
Re-enter new password:
Password updated successfully! Reloading privilege tables.. ...
Success!
FOR UBUNTU 18.04 OR mysql-server
version 5.7.22, THIS METHOD WILL NOT WORK
Follow these steps to set root password in 18.04:
As there is no password set for root user, simply login with blank password
sudo mysql -u root -p
Enter password: (press enter as no password is set)
after then can easily run query
ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
2
The problem in the case of this question is that the user can't get to the prompts you're mentioned because he doesn't know thecurrent password for root
.
– L. D. James
May 4 '16 at 5:12
@L.D.James yes,you're right. I don't remember about ERROR : 1405 when i runmysql_secure_installation
butsudo mysql_secure_installation
worked for me. mysql installation doesn't ask for password. It happened with me the same. andhere press enter
means press enter without password.
– d a i s y
May 4 '16 at 5:35
1
As concers ubuntu 18.04 or debian 9+ it won't connect with blank password and even after resetting pass for root, it still refuses to connect
– chefarov
Oct 11 at 18:04
add a comment |
up vote
24
down vote
up vote
24
down vote
It will not ask for the password while installing mysql
in Ubuntu 16.04 but you can set it after successful installation in following way:
After completion of mysql installation, run command:
sudo mysql_secure_installation
It will show:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and you
haven't set the root password yet, the password will be blank, so you
should just press enter here.
Enter current password for root (enter for none):
(here press Enter)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y (press 'y' to set new password)
New password:
Re-enter new password:
Password updated successfully! Reloading privilege tables.. ...
Success!
FOR UBUNTU 18.04 OR mysql-server
version 5.7.22, THIS METHOD WILL NOT WORK
Follow these steps to set root password in 18.04:
As there is no password set for root user, simply login with blank password
sudo mysql -u root -p
Enter password: (press enter as no password is set)
after then can easily run query
ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
It will not ask for the password while installing mysql
in Ubuntu 16.04 but you can set it after successful installation in following way:
After completion of mysql installation, run command:
sudo mysql_secure_installation
It will show:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and you
haven't set the root password yet, the password will be blank, so you
should just press enter here.
Enter current password for root (enter for none):
(here press Enter)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y (press 'y' to set new password)
New password:
Re-enter new password:
Password updated successfully! Reloading privilege tables.. ...
Success!
FOR UBUNTU 18.04 OR mysql-server
version 5.7.22, THIS METHOD WILL NOT WORK
Follow these steps to set root password in 18.04:
As there is no password set for root user, simply login with blank password
sudo mysql -u root -p
Enter password: (press enter as no password is set)
after then can easily run query
ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
edited Oct 29 at 3:28
answered May 4 '16 at 4:55
d a i s y
3,23982244
3,23982244
2
The problem in the case of this question is that the user can't get to the prompts you're mentioned because he doesn't know thecurrent password for root
.
– L. D. James
May 4 '16 at 5:12
@L.D.James yes,you're right. I don't remember about ERROR : 1405 when i runmysql_secure_installation
butsudo mysql_secure_installation
worked for me. mysql installation doesn't ask for password. It happened with me the same. andhere press enter
means press enter without password.
– d a i s y
May 4 '16 at 5:35
1
As concers ubuntu 18.04 or debian 9+ it won't connect with blank password and even after resetting pass for root, it still refuses to connect
– chefarov
Oct 11 at 18:04
add a comment |
2
The problem in the case of this question is that the user can't get to the prompts you're mentioned because he doesn't know thecurrent password for root
.
– L. D. James
May 4 '16 at 5:12
@L.D.James yes,you're right. I don't remember about ERROR : 1405 when i runmysql_secure_installation
butsudo mysql_secure_installation
worked for me. mysql installation doesn't ask for password. It happened with me the same. andhere press enter
means press enter without password.
– d a i s y
May 4 '16 at 5:35
1
As concers ubuntu 18.04 or debian 9+ it won't connect with blank password and even after resetting pass for root, it still refuses to connect
– chefarov
Oct 11 at 18:04
2
2
The problem in the case of this question is that the user can't get to the prompts you're mentioned because he doesn't know the
current password for root
.– L. D. James
May 4 '16 at 5:12
The problem in the case of this question is that the user can't get to the prompts you're mentioned because he doesn't know the
current password for root
.– L. D. James
May 4 '16 at 5:12
@L.D.James yes,you're right. I don't remember about ERROR : 1405 when i run
mysql_secure_installation
but sudo mysql_secure_installation
worked for me. mysql installation doesn't ask for password. It happened with me the same. and here press enter
means press enter without password.– d a i s y
May 4 '16 at 5:35
@L.D.James yes,you're right. I don't remember about ERROR : 1405 when i run
mysql_secure_installation
but sudo mysql_secure_installation
worked for me. mysql installation doesn't ask for password. It happened with me the same. and here press enter
means press enter without password.– d a i s y
May 4 '16 at 5:35
1
1
As concers ubuntu 18.04 or debian 9+ it won't connect with blank password and even after resetting pass for root, it still refuses to connect
– chefarov
Oct 11 at 18:04
As concers ubuntu 18.04 or debian 9+ it won't connect with blank password and even after resetting pass for root, it still refuses to connect
– chefarov
Oct 11 at 18:04
add a comment |
up vote
14
down vote
Apparently the mysql-server installation on 16.04 (or any 5.7 installation?) allows root access not through password, but through the auth_socket plugin. Running sudo mysql -u root
(n.b. w/o a password) will give you mysql console whereas running the command as non-root prompts you for a password.
It would seem that changing the password doesn't make much of a difference since the auth backend doesn't even check for a password. There is a very comprehensive article on how to change the plugin and switch to password authentication.
3
I was able to confirm with a fresh installation ofapt install mysql-server
without specifying a password on 18.04. The symptom and solution is exactly as described.
– EricC
Jun 18 at 2:45
add a comment |
up vote
14
down vote
Apparently the mysql-server installation on 16.04 (or any 5.7 installation?) allows root access not through password, but through the auth_socket plugin. Running sudo mysql -u root
(n.b. w/o a password) will give you mysql console whereas running the command as non-root prompts you for a password.
It would seem that changing the password doesn't make much of a difference since the auth backend doesn't even check for a password. There is a very comprehensive article on how to change the plugin and switch to password authentication.
3
I was able to confirm with a fresh installation ofapt install mysql-server
without specifying a password on 18.04. The symptom and solution is exactly as described.
– EricC
Jun 18 at 2:45
add a comment |
up vote
14
down vote
up vote
14
down vote
Apparently the mysql-server installation on 16.04 (or any 5.7 installation?) allows root access not through password, but through the auth_socket plugin. Running sudo mysql -u root
(n.b. w/o a password) will give you mysql console whereas running the command as non-root prompts you for a password.
It would seem that changing the password doesn't make much of a difference since the auth backend doesn't even check for a password. There is a very comprehensive article on how to change the plugin and switch to password authentication.
Apparently the mysql-server installation on 16.04 (or any 5.7 installation?) allows root access not through password, but through the auth_socket plugin. Running sudo mysql -u root
(n.b. w/o a password) will give you mysql console whereas running the command as non-root prompts you for a password.
It would seem that changing the password doesn't make much of a difference since the auth backend doesn't even check for a password. There is a very comprehensive article on how to change the plugin and switch to password authentication.
answered Nov 12 '16 at 9:57
carp
24123
24123
3
I was able to confirm with a fresh installation ofapt install mysql-server
without specifying a password on 18.04. The symptom and solution is exactly as described.
– EricC
Jun 18 at 2:45
add a comment |
3
I was able to confirm with a fresh installation ofapt install mysql-server
without specifying a password on 18.04. The symptom and solution is exactly as described.
– EricC
Jun 18 at 2:45
3
3
I was able to confirm with a fresh installation of
apt install mysql-server
without specifying a password on 18.04. The symptom and solution is exactly as described.– EricC
Jun 18 at 2:45
I was able to confirm with a fresh installation of
apt install mysql-server
without specifying a password on 18.04. The symptom and solution is exactly as described.– EricC
Jun 18 at 2:45
add a comment |
up vote
0
down vote
Adding to the main answer, If you are stuck at
"mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql"
1 thing to remember that you have to use another terminal window to enter the following command.
$ sudo mysql --user=root mysql
If you try to do it in the same window, it will shut down the mysqld safemode process.
add a comment |
up vote
0
down vote
Adding to the main answer, If you are stuck at
"mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql"
1 thing to remember that you have to use another terminal window to enter the following command.
$ sudo mysql --user=root mysql
If you try to do it in the same window, it will shut down the mysqld safemode process.
add a comment |
up vote
0
down vote
up vote
0
down vote
Adding to the main answer, If you are stuck at
"mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql"
1 thing to remember that you have to use another terminal window to enter the following command.
$ sudo mysql --user=root mysql
If you try to do it in the same window, it will shut down the mysqld safemode process.
Adding to the main answer, If you are stuck at
"mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql"
1 thing to remember that you have to use another terminal window to enter the following command.
$ sudo mysql --user=root mysql
If you try to do it in the same window, it will shut down the mysqld safemode process.
answered Sep 15 '17 at 8:03
Mohd Abdul Mujib
1214
1214
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f766900%2fmysql-doesnt-ask-for-root-password-when-installing%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