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
I’m so sorry, but this doesn’t work for me, at all.
It still returns:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
did you install via services.mysql.*
options? and is the database service currently running?
Yes, I did, which resolved the initial error (i.e. I did services.mysql = true
, and set the package to mysql84. However I’m having a slew of very confusing error messages from MySql, especially with regards to permissions. Whenever I run mysql -u root
, It either gives an error message on the password not being set, or that Acess Denied for user 'root'@'localhost'
. I have not set any passwords, and it’s absurd that MySQL will set one for you and I can’t find it
I later fixed this by tanking the installation, clearing the var/lib/mysql
folder, rebuilding the system with mysql 8.4, and I immediately ran the mysql_secure_installation
with admin priviledges
1 Like