I'm trying to run a server in python/django and I'm getting the following error:
django.db.uils.OperationslError: (200, "Can't connect to local MySQL
server through socket '/tmp/mysql.sock' (2)").
I have MySQL-python installed (1.2.5 version) and mysql installed (0.0.1), both via pip, so I'm not sure why I can't connect to the MySQL server. Does anyone know why? Thanks!
You can't install mysql through pip; it's a database, not a Python library (and it's currently in version 5.7). You need to install the binary package for your operating system.
Related
I am trying to build an application in python which will use Oracle Database installed in corporate server and the application which I am developing can be used in any local machine.
Is it possible to connect to oracle DB in Python without installing the oracle client in the local machine where the python application will be stored and executed?
Like in Java, we can use the jdbc thin driver to acheive the same, how it can be achieved in Python.
Any help is appreciated
Installing oracle client, connect is possible through cx_Oracle module.
But in systems where the client is not installed, how can we connect to the DB.
You can use JDBC
"""
Connect from Python to Oracle via JDBC
Get JDBC-driver here: https://download.oracle.com/otn/utilities_drivers/jdbc/193/ojdbc8-full.tar.gz
Python 3.7.4
conda install -c conda-forge jaydebeapi==1.1.1 --force-reinstall -y
conda install -c conda-forge JPype1==0.6.3 --force-reinstall -y
"""
import jpype
import jaydebeapi
JHOME = jpype.getDefaultJVMPath()
jpype.startJVM(JHOME, '-Djava.class.path=/ojdbc8-full/ojdbc8.jar')
con = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver',
'jdbc:oracle:thin:user/pass#host_ip:1521:SID')
cur = con.cursor()
cur.execute('select dummy from dual')
r = cur.fetchall()
print(r[0][0])
cur.close()
con.close()
It is not correct that java can connect to oracle without any oracle provided software.
It needs a compatible version of ojdbc*.jar to connect. Similarly python's cx_oracle library needs oracle instant-client software from oracle to be installed.
Instant client is free software and has a small footprint.
Installing Oracle client is a huge pain. Could you instead create a Webservice to a system that does have OCI and then connect to it that way? This might end being a better solution rather than direct access.
I'm new to python and django. When I run python manage.py runserver I get this error:
django.db.utils.OperationalError: (2026, 'SSL connection error: SSL_CTX_set_tmp_dh failed')'
mysql Server version: 8.0.13 MySQL Community Server - GPL.
I can't find this error on the web.
I had this issue too when installing from Anaconda, but I could work around it using the "use_pure=True" mysql.connector.connect() parameter.
I ran into the same error when I tried to connect to MySQL to Python (in Anaconda).
This feed is particularly helpful for various case scenarios leading to the same error. For me, installing openSSL version 1.0.2r in Anaconda, itself, fixed the issue:
$ conda install openssl=1.0.2r
I got the answer:'https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization.html'
'shell> bin/mysql_ssl_rsa_setup'
Open The file init.py(file under the same directory as settings.py)
add the following code:
import pymysql
pymysql.install_as_MySQLdb()
I use the following line of code in order to connect to a database instance of my computer.
cnx = mysql.connector.connect(host=Host, user=User, password=Password, database=db, auth_plugin='mysql_native_password')
The connection works perfectly both at the the spyder console and at the executable (.exe) that I made from this code. The problem is that when I try to run this executable remotely from another computer and connect to the database instance of my computer (my IP) I get this authentication plugin error. Should I change something to the settings of mysql database? I need the code to run both locally at my PC and remotely at any other.
I had the error while connecting to MySql database as :
in get_auth_plugin mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
Which had removed by using windows command line window:
pip uninstall mysql-connector-python
pip install mysql-connector-python
I ran the following in the terminal:
sudo port install py26-mysql
sudo port install mysql5-server
It seems to have downloaded and installed properly, but when I try to open mysql using /opt/local/lib/mysql5/bin/mysql I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
Does anyone know what's gone wrong?
Did you activate the MySQL server? See the instructions under Step 3: Install MySQL.
You have to add to /opt/local/etc/mysql57/my.cnf the following configuration:
[client]
socket=/opt/local/var/run/mysql57/mysqld.sock
[mysqld]
socket=/opt/local/var/run/mysql57/mysqld.sock
I installed XAMPP on my Mac (Snow Leopard) and installed Django. How do I tell Django to use this and when I fire up python manage.py runserver I get this error:
...
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)")
How do I tell Django to use this instead?
/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Put that in the HOST entry for the database in the settings.
simple solution is that just install Django Stack for Xampp. Not need to configure any thing every thing is configured already
https://wiki.bitnami.com/Infrastructure_Stacks/BitNami_Django_Stack