mariadb login as normal user

in mariadb you cannot login with normal user, you must use sudo or equal with that, the solution …

  1. connect with sudo to mysql
    sudo mysql -u root
  2. check your account in present db
    mysql> SELECT User,Host FROM mysql.user;
    +------------------+-----------+
    | User             | Host      |
    +------------------+-----------+
    | root             | localhost |
  3. recreate user root
    mysql> CREATE USER 'root'@'%' IDENTIFIED BY '';
    Query OK, 0 rows affected (0,00 sec)
  4. give permission
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
    Query OK, 0 rows affected (0,00 sec)
  5. flush
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0,01 sec)
    
  6. show database user
    SELECT User,Host FROM mysql.user;
    +------+-----------+
    | User | Host      |
    +------+-----------+
    | root | %         |
    | root | localhost |
    +------+-----------+
  7. exit and connect with normal user
    mysql -u root

Published by

G3n1k

just to remember what i had known :)