Skip to content

Instantly share code, notes, and snippets.

@rohsyl
Last active December 30, 2023 19:09
Show Gist options
  • Save rohsyl/e1d459ccd582774e594e3ff3358528d5 to your computer and use it in GitHub Desktop.
Save rohsyl/e1d459ccd582774e594e3ff3358528d5 to your computer and use it in GitHub Desktop.
MariaDB switch to mysql_native_password

Switch to mysql_native_password plugin

By default MariaDB use the unix_socket plugin to authenticate users.

But it's easier to use mysql_native_password for dev (and only for dev because it's way less secure).

Get root access

sudo su

Connect to mysql

mysql

Run this query

ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;
SET PASSWORD = PASSWORD('foo');

And then

flush privileges;

Enjoy !

@Nilpo
Copy link

Nilpo commented May 12, 2022

This no longer works in modern version of MariaDB 10.4.3+. Use this query instead.

ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;
SET PASSWORD = PASSWORD('foo');

You can also find more information at https://mariadb.com/kb/en/authentication-plugin-unix-socket/.

@akrambazina
Copy link

Works with Mariadb 10.3 perfect. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment