Sqlacodegen - unable to connect to database

I am trying to use sqlacodegen

on mine database

.

sqlacodegen mysql://root:mypassword@localhost/database_name

      

However, I keep getting this error:

sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")

      

However, in my application, flask

I am accessing this same database

without issue.

This file doesn't exist on my system, so I went to /etc/mysql/my.cnf

and changed the line:

socket      = /var/run/mysqld/mysqld.sock

      

to

socket      = /opt/lampp/var/mysql/mysql.sock

      

Not really sure if this was the right thing to do. However, even after this change, the systems seem to still be trying to launch from their original location.

+3


source to share


1 answer


you can just create a symbolic link in /var/run/mysqld/mysqld.sock

lampp mysql sock.

sudo ln -s /opt/lampp/var/mysql/mysql.sock/ /var/run/mysqld/mysqld.sock

      



restart lampp mysql

sudo /opt/lampp/lampp stopmysql
sudo /opt/lampp/lampp startmysql

      

0


source







All Articles