Why is Hibernate not creating database for MySQL?

后端 未结 3 1627
Happy的楠姐
Happy的楠姐 2021-01-19 03:48

I have following hibernate.cfg.xml:




        
相关标签:
3条回答
  • 2021-01-19 04:24

    My thoughts are that your MySQL doesn't have a schema for your database. So, at least you should go to check if it exists. I use MySQL Workbench (quite nice tool), so just check/create it there if it doesn't exist and try again.

    0 讨论(0)
  • 2021-01-19 04:29

    MySQL will create your schema within a database, but will not create your actual database for you. You must have an existing database called 'userdb' in your local MySQL installation (log in and run something like 'create database userdb') before you run the schema export in hibernate.

    0 讨论(0)
  • 2021-01-19 04:34

    I usually use the properties file to automatically create a database when i'm using Spring, and below is how its done, hope this works so u'll modify this to suite your needs.....

    database.driver=com.mysql.jdbc.Driver
    database.url=jdbc:mysql://localhost:3306/userdb?createDatabaseIfNotExist=true
    database.user=root
    database.password=root
    hibernate.dialect=org.hibernate.dialect.MySQLDialect
    hibernate.show_sql=true
    hibernate.hbm2ddl.auto=create
    
    0 讨论(0)
提交回复
热议问题