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) ...
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
– llamerr Jul 18 '16 at 16:51$ mysql_upgrade -u root -p
. Also try the command above given by RP Singh . – L. D. James Aug 04 '16 at 13:16SET PASSWORD FOR 'root' = PASSWORD('your-password')
if you are using mariadb – user1036719 Aug 08 '19 at 03:14FLUSH PRIVILEGES;
, execute one more query:UPDATE user SET plugin='mysql_native_password';
so that the MySQL server uses its native password plugin to authenticate. – Aryo Mar 04 '20 at 00:11UPDATE user SET plugin='mysql_native_password'
– Arun Apr 24 '20 at 14:12PASSWORD
function. – Flimm Jan 04 '21 at 09:33ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
– scrollout Jun 22 '23 at 22:28