Accessing a XAMPP mysql via Python

后端 未结 3 1613
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-09 08:24

I\'m attempting to use mysql after only having worked with sqlite in the past.

I\'ve installed XAMPP on Linux (ubuntu) and have mysql up and ru

相关标签:
3条回答
  • 2021-02-09 09:02

    Have the same issue using and look for your SQL configuration file my.cnf.

    # The following options will be passed to all MySQL clients
    [client]
    #password   = your_password
    port        = 3306
    socket      = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
    

    and use socket as parameter:

    mysql://read:read@localhost/phonehome?unix_socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
    

    In my case:

    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://read:read@localhost/phonehome?unix_socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'
    
    0 讨论(0)
  • 2021-02-09 09:04

    For the record (and thanks to a pointer from Igancio), I found that the below works (terrible I didn't think of this before):

    db=MySQLdb.connect(
       user="root"
      ,passwd=""
      ,db="my_db"
      ,unix_socket="/opt/lampp/var/mysql/mysql.sock")
    
    0 讨论(0)
  • 2021-02-09 09:18

    It means that you didn't start the MySQL server, or it's configured to not use a domain socket.

    0 讨论(0)
提交回复
热议问题