I installed mysql through yum just now and the OS fedora installed mariadb for me. I know mariadb is a new branch of mysql, but I can't understand why it does not ask me for setting the password. I have tried for 123456 and so on, but I failed. My fedora is new, and this is the first time to install mysql/mariadb. What should I do for it?
213 Answers
I had the same problem. It's true the password is empty, but even so the error message is shown. The solution is just using "sudo" so
$ sudo mysqlwill open the mysql tool
For securing the database, you should use sudo again.
$ sudo mysql_secure_installation 4 From :
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.
the password will be blank
I think that's your answer.
5mariadb uses by defaults UNIX_SOCKET plugin to authenticate user root.
"Because he has identified himself to the operating system, he does not need to do it again for the database"
so you need to login as the root user on unix to login as root in mysql/mariadb:
sudo mysqlif you want to login with root from your normal unix user, you can disable the authentication plugin for root.
Beforehand you can set the root password with mysql_secure_installation (default password is blank), then to let every user authenticate as root login with:
shell$ sudo mysql -u root
[mysql] use mysql;
[mysql] update user set plugin='' where User='root';
[mysql] flush privileges;
[mysql] \q 3 The default password is empty. More accurately, you don't even NEED a password to login as root on the localhost. You just need to BE root. But if you need to set the password the first time (if you allow remote access to root), you need to use:
sudo mysql_secure_installationEnter empty password, then follow the instructions.
The problem you are having is that you need to BE root when you try to login as root from the local machine.
On Linux: mariadb will accept a connection as root on the socket (localhost) ONLY IF THE USER ASKING IT IS ROOT. Which means that even if you try
mysql -u root -pAnd have the correct password you will be refused access. Same goes for
mysql_secure_installationMariadb will always refuse the password because the current user is not root. So you need to call them with sudo (or as the root user on your machine) So locally you just want to use:
sudo mysqland
sudo mysql_secure_installationWhen moving from mysql to mariadb it took a while for me to figure this out.
Lucups, Floris is right, but you comment that this didn't solve your problem. I ran into the same symptoms, where mysql (mariadb) will not accept the blank password it should accept, and '/var/lib/mysql' does not exist.
I found that this Moonpoint.com page was on-point. Perhaps, like me, you tried to start the mysqld service instead of the mariadb service. Try:
systemctl start mariadb.service
systemctl status mysqld serviceFollowed by the usual:
mysql_secure_installation 1 Had the same issue after installing mysql mariadb 10.3. The password was not NULL so simply pressing ENTER didn't worked for me. So finally had to change the password. I followed instruction from here. In nutshell; stop the server
sudo systemctl stop mariadb.servicegain access to the server through a backdoor by starting the database server and skipping networking and permission tables.
sudo mysqld_safe --skip-grant-tables --skip-networking &login as root
sudo mysql -u rootthen change server password
use mysql;
update user set password=PASSWORD("new_password_here") where User='root';Note that after MySQL 5.7, the password field in mysql.user table field was removed, now the field name is 'authentication_string'. So use appropriate table name based on mysql version. finally save changes & restart the server
flush privileges;
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service 2 If your DB is installed properly and typed the wrong password, the error thrown will be:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
The following error indicates you DB hasn't been started/installed completely. Your command is not able to locate and talk with your DB instance.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
Good practice would be to change your password after a fresh install
$ sudo service mysql stop
$ mysqld_safe --skip-grant-tables &
$ sudo service mysql start
$ sudo mysql -u root
MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set password=PASSWORD("snafu8") where User='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> exit;
$ sudo service mysql restartOR
mysqladmin -u root password 'enter password here' 1 The default password for Mariadb is blank.
$ mysql -u root -p
Enter Password: <--- press enter 1 I believe I found the right answers from here.
So in general it says this:
user: root
password: password
That is for version 10.0.15-MariaDB, installed through Wnmp ver. 2.1.5.0 on Windows 7 x86
just switch your current logged-in user to the root and login without password mysql -uroot
1I hit the same issue and none of the solutions worked. I then bumped an answer in stackexchange dba which lead to this link. So here is what I did:
- ran
sudo mysqld_safe --skip-grant-tables --skip-networking & - ran
sudo mysql -urootand got into mysql console - run
ALTER USER root@localhost identified via unix_socket;andflush privileges;consecutively to allow for password-less login
If you want to set the password then you need to do one more step, that is running ALTER USER root@localhost IDENTIFIED VIA mysql_native_password; and SET PASSWORD = PASSWORD('YourPasswordHere'); consecutively.
UPDATE
Faced this issue recently and here is how I resolved it with recent version, but before that some background. Mariadb does not require a password when is run as root. So first run it as a root. Then once in the Mariadb console, change password there. If you are content with running it as admin, you can just keep doing it but I find that cumbersome especially because I cannot use that with DB Admin Tools. TL;DR here is how I did it on Mac (should be similar for *nix systems)
sudo mariadb-secure-installation
then follow instructions on the screen!
Hope this will help someone and serve me a reference for future problems
0By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
1For me, password = admin, worked. I installed it using pacman, Arch (Manjaro KDE).
NB: MariaDB was already installed, as a dependency of Amarok.