Is it possible to change the port Redash connects to Postgres?
I had initially set-up Redash successfully and connected to Postgres, but after a few days, it was impossible to start Postgres on port 5432. I even tried reinstalling but it forcefully sets the port to 5433. I have tried to change the port to 5433 on redash/query_runner/pg.py but there is no change.
How can I change the port flask listens to, to 5433 or any other for that matter?
The file 'query_runner/pg.py' is designed to connnect remote database like mysql.py, oracle.py and so on. It's not the backend database saving users' infomation. So you should try to change the value like
SQLALCHEMY_DATABASE_URI = os.environ.get(
"REDASH_DATABASE_URL", os.environ.get("DATABASE_URL", "postgresql:///postgres"))
It is in 'redash/settings/__init__.py', but I am sorry that I don't know the detail about how to change it.
Related
I have trouble connecting to my mySQL database remotely through Python.
I use the following to connect to mySQL:
import mysql.connector
cnx = mysql.connector.connect(host='XXX.XXX.XXX.X',user='XXXX',password='XXXXXX',database='testdb')
But I get the following error:
2003: Can't connect to MySQL server on '%HOST%:3306' (10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)
The server is running and when I run the same code on the computer I run the server from using 'localhost'
import mysql.connector
cnx =
mysql.connector.connect(host='localhost',user='XXXX',password='XXXXXX',database='testdb')
it works and I can modify the data in the database. I'm trying to connect it remotely from another computer though.
I've tried using GRANT ALL ON *.* TO User#Host IDENTIFIED BY 'password'; but no result. I checked my firewall and allowed all incoming and outgoing connections through port 3306 which is used by default.
I'm new to mySQL and really have no clue what to do. I don't even know if I use the correct hostname :') I use the IP address of the computer I run the server from,I think that's right.
You dont need to GRANT ALL privilage to the user. You need to tell MYSQL that this user is allowed to login from a remote location.
In fact as you are allowing remote access through this user account now, you should make sure that it can access only the database(s) it needs to, and definitely cannot use GRANT
For example
CREATE USER 'myuser'#'%' IDENTIFIED BY 'mypass';
Will allow this user to connect from any ip address. To be more secure you should try to be more specific and specify a individual ip address if you can
CREATE USER 'myuser'#'11.22.33.44' IDENTIFIED BY 'mypass';
Remember, you are creating a new user account here because you already have a
myuser#localhost
Either way you need to make sure that the password is a strong one, specially is you use the % any ip option
We have to servers. I have installed MongoDB on one of the servers (UBUNTU - Digital Ocean VPS).
When I run a script to retrieve data from the same server using a localhost, I can do that perfectly.
import pymongo
//SERVER = 'mongodb://localhost:27017/myproject'
SERVER = 'mongodb://root:password#x.x.x.x:27017/myproject' where x.x.x.x is the address of my server
connection=pymongo.MongoClient(SERVER)
db = connection.myproject
print list(db.coll.find())
The problem is thqt I can't connect to this DB. Note that I can ssh and run the script using localhost inside the server; but not the case out of the server.
Do I need to go through some configuration:
You must allow remote access
vi /etc/mongod.conf
Listen only local interface.
bind_ip = 127.0.0.1
you must add the IP of your other servers. For Example:
Listen local interface and 192.168.0.100.
bind_ip = 127.0.0.1, 192.168.0.100
Comment out to listen on all interfaces
Nota: Comma Separated
I hope to help
For development purposes you can open an ssh tunnel like
ssh <UBUNTU - Digital Ocean VPS> -L27018:localhost:27017
and then connect to the remote db as
SERVER = 'mongodb://root:password#localhost:27018/myproject'
while ssh connection remains open. You can use any free port instead of 27018.
Otherwise you need to reconfigure mongodb to listen to all interfaces. Comment out bindIp line in mongodb config and restart the server. This will make the DB publicly accessible, so make sure you use strong passwords and don't allow anonymous access.
Finally, if you are using VPN, you need to uncomment bindIp line in the mongodb config, and add VPN interface there, e.g.:
bindIp = 127.0.0.1,10.0.1.12
where 10.0.1.12 should be replaced with vpn interface of your ubuntu box. You can find exact value with ifconfig. Important: there are no spaces around coma.
I have a Bitnami MEAN Stack running on AWS EC2. I'm trying to connect from a remote machine using PyMongo.
from pymongo import MongoClient
conn = MongoClient('mongodb://username:password#ec2blah.us-east-1.compute.amazonaws.com:27017/dbname')
but I keep getting an error along the lines of pymongo.errors.ConnectionFailure: timed out
I have edited /opt/bitnami/mongodb/mongodb.conf to supposedly allow external connections by commenting out bind_ip = 127.0.0.1 and uncommented bind_ip = 0.0.0.0 and all permutations of commenting/uncommenting those lines.
I've looked over the web for about 90 minutes now trying different things but without luck!
On the mongoDB server, do the port connection test, and make sure the DB service running well. If not, start the service.
telnet ec2blah.us-east-1.compute.amazonaws.com 27017
On the remote machine, do the port connection test, to make sure there is no firewall issue.
telnet ec2blah.us-east-1.compute.amazonaws.com 27017
If you have issue to connect, you need check security groups on this instance.
Click the ec2 instance name --> Description --> view rules, you should see the ports are opened
If not, create a new security group , such as `mongoDB`, tcp port 27017 should be opened for inbound traffic, then assign to that instance.
You should be fine to connect it now.
At the time of start-up of MongoDB, set the bind_ip argument to ::,0.0.0.0
mongod --bind_ip ::,0.0.0.0
Read more in the docs of MongoDB: IP Binding.
This is how i connect to MySQL via WSGI-Python
def a():
b=_mysql.connect('localhost','1','','z',3333)
return b
in other words i changed the MySQL port from 3306 to 3333
and then added it here.
but it turns out.. this has no effect what so ever.
even without a port number i can seem to be able to connect to MySQL just fine.
is it perhaps because it is "localhost" ?
but what is even more.. when i place a wrong port number there..
it has no effect what so ever.
can this also be due to because it is a localhost ?
UPDATE
i changed
localhost
to
127.0.0.1
it seems to have effect now.
Make sure this line is in your hosts file
127.0.0.1 localhost
and is not commented out.
I need to SSH into a db using Python, I'm using PythonDB for this. I saw this question which details how to do this but I can't seem to get the syntax right. Would someone be able to point me in the right direction....? I also need to use a private key, how would I go about inserting that...?
ssh -L 9990:127.0.0.0:3396 <79.xxx.xx.xxx>
database = MySQLdb.connect(host'127.0.0.0', port=3306, user='jack', passwd='pass', db='test')
As said in the answer to the other question in the ssh-tunnel you are forwarding from port 9990 on your local machine to the (standard mysql) port on the remove machine. To send requests through that ssh-tunnel you need to connect to port 9990 instead of 3306:
database = MySQLdb.connect(host'127.0.0.0', port=9990, ....