Help me setup mysql in nixos

So i’m trying to setup mysql, I’m installed mysql in configuration.nix, and when i try to run this cmd:
mysql
i get an error :
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)

please keep it simple so i can understand, ik i have to setup some socket for authetication and I just don’t know how :')

try sudo mysql -u root maybe?

1 Like

yes it worked, thank you so much. just another quick question, i can’t create table no insert data from laravel ORM , how can i fix that, error:

pluh@nixos > php artisan migrate
   Illuminate\Database\QueryException

  SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'oneessr' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:813
    809▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    810▕                 );
    811▕             }
    812▕
  ➜ 813▕             throw new QueryException(
    814▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    815▕             );
    816▕         }
    817▕     }

      +38 vendor frames

  39  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

you should consider creating a separate user for your laravel application and assigning permissions based on that

are you familiar with managing users in mysql? if not then here is a random link focused on laravel from a quick search which should cover you

2 Likes

it’s working , I appreciate your help, thank you