Reputation: 75
I would like to host a database on my raspberry pi to which I can access from any device. I would like to access the contents of the database using python.
What I've done so far:
Now my goal is to be able to connect to the database using python from my laptop. But I seem to have an error connecting to it, this is what I wrote to connect to it.
db = MySQLdb.connect("192.168.3.14","root","12345","test" )
Any help or direction is appreciated.
Upvotes: 0
Views: 114
Reputation: 11
on the terminal of your raspi use the following command: mysql -u -p -h --port
where you switch out your hostname with your ip address. since currently you can only connect via local host
Upvotes: 1
Reputation: 1591
The reason why you are not able to connect to the database from outside of localhost is that the remote access for the root user is prohibited by default, i.e. you can only access the database with the root user from localhost. You can, however, change this by tweaking root's privileges. Please take a look here to find out how the user privileges need to be change to make this work.
Upvotes: 0
Reputation: 164
at first step is check you haven't firewall rules on raspberry or in your lattop
after you can try this command on mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
and remember to apply new privileges
FLUSH PRIVILEGES;
for more detail you can see https://dev.mysql.com/doc/refman/5.7/en/grant.html
is similar for mariadb ecc...
Upvotes: 0