Hi,
I'm using Python2.1 and MySQL-3.22.32 on RedHat 6.2. MySQL is under /usr/src... When I import MySQLdb from the command prompt I get the following message:
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.1/MySQLdb.py", line 27 in ?
type_conv = {FIELD_TYPE.TINY:int,
NameError: name 'FIELD_TYPE' not defined
If I import MySQLdb again no errors are rased. Any ideas what I'm doing wrong?
Also I then typed db=MySQLdb.connect('','')
and I get an OperationalError:2002,
Cant connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)"
mysql.sock is in /tmp
can I change where MySQLdb looks for this or should I reinstall MySQL
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You don't say what version of MySQLdb you have. If it's an error in MySQLdb.py, you either have a pre-0.9.0 version, or you installed 0.9.0+ over an older version. MySQLdb became a package as of 0.9.0, so if you are using 0.9.0 or newer, get rid of MySQLdb.py.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Andy, that gor rid of the first problem but the second remains:
I've installed MySQL-python-0.9.1 with Python2.1 and MySQL-3.22.32 on RedHat 6.2. MySQL is under /usr/src...
I type db=MySQLdb.connect('','')
and I get an OperationalError:2002,
Cant connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)"
mysql.sock is in /tmp
can I change where MySQLdb looks for this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems that if you install MySQL as a binary you get a different file structure than you do if you install MySQL as a source/RPM. in the latter the .sock is in '/var/lib/mysql/mysql.sock' in the former it's in '/tmp/mysql.sock'
I'm trying to figure out how MySQLdb 0.9.1 gets it's mysql.sock reference. I think it comes from _mysql.c ???. I have a binary installation with the .sock in /tmp/ but MySQLdb always looks in '/var/lib/mysql/mysql.sock' I've also set the MYSQL_UNIX_PORT env variable to /tmp/mysql.sock in the hope that MySQLdb uses it ? anybody know where to go from here?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just to let anyone with this problem know, setting MYSQL_UNIX_PORT did the job!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-04-23
how to change the MYSQL_UNIX_PORT env variable??
where is it?
I used the other way to connect to MySQL when my mysql.sock is not in /var/lib/mysql too.
Add the parameter unix_socket in _mysql.connect() will work successfully
but I suggest this way may annoy me a lot because I need remember the right path of mysql.sock when I need to connect mysql everytime
and if scripture need to move to another platform.....this will induce a big problem...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm using Python2.1 and MySQL-3.22.32 on RedHat 6.2. MySQL is under /usr/src... When I import MySQLdb from the command prompt I get the following message:
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.1/MySQLdb.py", line 27 in ?
type_conv = {FIELD_TYPE.TINY:int,
NameError: name 'FIELD_TYPE' not defined
If I import MySQLdb again no errors are rased. Any ideas what I'm doing wrong?
Also I then typed db=MySQLdb.connect('','')
and I get an OperationalError:2002,
Cant connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)"
mysql.sock is in /tmp
can I change where MySQLdb looks for this or should I reinstall MySQL
You don't say what version of MySQLdb you have. If it's an error in MySQLdb.py, you either have a pre-0.9.0 version, or you installed 0.9.0+ over an older version. MySQLdb became a package as of 0.9.0, so if you are using 0.9.0 or newer, get rid of MySQLdb.py.
Thanks Andy, that gor rid of the first problem but the second remains:
I've installed MySQL-python-0.9.1 with Python2.1 and MySQL-3.22.32 on RedHat 6.2. MySQL is under /usr/src...
I type db=MySQLdb.connect('','')
and I get an OperationalError:2002,
Cant connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)"
mysql.sock is in /tmp
can I change where MySQLdb looks for this?
It seems that if you install MySQL as a binary you get a different file structure than you do if you install MySQL as a source/RPM. in the latter the .sock is in '/var/lib/mysql/mysql.sock' in the former it's in '/tmp/mysql.sock'
I'm trying to figure out how MySQLdb 0.9.1 gets it's mysql.sock reference. I think it comes from _mysql.c ???. I have a binary installation with the .sock in /tmp/ but MySQLdb always looks in '/var/lib/mysql/mysql.sock' I've also set the MYSQL_UNIX_PORT env variable to /tmp/mysql.sock in the hope that MySQLdb uses it ? anybody know where to go from here?
Just to let anyone with this problem know, setting MYSQL_UNIX_PORT did the job!
how to change the MYSQL_UNIX_PORT env variable??
where is it?
I used the other way to connect to MySQL when my mysql.sock is not in /var/lib/mysql too.
Add the parameter unix_socket in _mysql.connect() will work successfully
but I suggest this way may annoy me a lot because I need remember the right path of mysql.sock when I need to connect mysql everytime
and if scripture need to move to another platform.....this will induce a big problem...