Shantanu24
Posts: 19
Joined: Fri Dec 30, 2016 6:28 am

Connect to MySQL on Laptop using Raspberry pi

Tue Feb 28, 2017 9:25 am

Hi.
I have a MySQLdb running on my Ubuntu Laptop. I have created a database.
I need to access this database on my laptop from my Raspberry pi.

I have installed PyMySQL on my raspberry pi. I have also configured the mysqld.conf file in my laptop and commented out the bind address line.

But eherytime i use the following command on my RPi

Code: Select all

conn = pymysql.connect(host='192.168.10.7', port='3306', user='root', passwd='password', db='temps')
192.168.10.7 is my laptop ip address. This IP address can be pinged from my RPi.

but i get error

Code: Select all

[code]pymysql.err.InternalError: (1130, "Host '192.168.10.7' is not allowed to connect to this MSQL server")
[/code]

Do I need to make anymore changes in the configuration? If yes, can you please guide me?

User avatar
omegaman477
Posts: 148
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: Connect to MySQL on Laptop using Raspberry pi

Tue Feb 28, 2017 1:27 pm

By default MySQL users are created so that they can only login from localhost. I suspect that is your issue.

Either specify a hostname for the user account, or use the % wildcard for any host.

[url]See: https://dev.mysql.com/doc/refman/5.7/en ... users.html[/url]
..the only thing worse than a stupid question is a question not asked.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Connect to MySQL on Laptop using Raspberry pi

Tue Feb 28, 2017 8:17 pm

You a) need to ensure MySQL is listening on the INADDR_ANY (0.0.0.0) address not localhost and b) that you've got a user defined that can be used from any machine on your LAN.

viewtopic.php?p=1045126#p1045126
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Beginners”