# Changing database from SQlite to Mysql

**URL:** <https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169>\
**Category:** Product Support\
**Created:** [April 28, 2016, 7:58pm UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169 "2016-04-28T19:58:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![varadarajan](https://avatars.discourse-cdn.com/v4/letter/v/898d66/32.png) [@varadarajan](https://forum.opennebula.io/u/varadarajan)\
**Post date:** [April 28, 2016, 7:58pm UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/1 "2016-04-28T19:58:17Z")

</div>

I followed the steps mentioned for changing to Mysql but I am unable to log in. I think I am doing something basically wrong. Can I change to Mysql after using SQlite for some time ? Or it should be done on a fresh install before starting first time ?

---

<div class="post-metadata">

**Author:** ![varadarajan](https://avatars.discourse-cdn.com/v4/letter/v/898d66/32.png) [@varadarajan](https://forum.opennebula.io/u/varadarajan)\
**Post date:** [May 1, 2016, 10:31pm UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/2 "2016-05-01T22:31:34Z")

</div>

Found the answer here.

> [@Oned failed to start /usr/bin/one: line 117](https://forum.opennebula.io/t/oned-failed-to-start-usr-bin-one-line-117/517):
>
> I have freshly installed opennebula + mysql. but oned wont start. it fails with: oned failed to start /usr/bin/one: line 117: 3572 Terminated $ONE\_SCHEDULER and in logfile: [ONE][E]: Password file /var/lib/one//.one/sunstone\_auth already exists but OpenNebula is boostraping the database. Check your database configuration in oned.conf. my database conf in oned.conf is correct: DB = [ backend = "mysql", server = "localhost", port = 0, user = "opennebula",…

---

<div class="post-metadata">

**Author:** ![Yenya](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/yenya/32/4624_2.png) [@Yenya](https://forum.opennebula.io/u/Yenya)\
**Post date:** [May 2, 2016, 8:26am UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/3 "2016-05-02T08:26:44Z")

</div>

It seems that oned thinks the database is uninitialized, but the rest of the setup (.one/sunstone\_auth etc.) does already exist. You have two possibilities:

either dump the original sqlite db, convert the dump to the MySQL format, insert the result to MySQL, and finally run “onedb fsck”,

or create a fresh installation, without any locally set up data such as ~/.one/sunstone\_auth.

For my ONe cloud, i went the first way, and it worked.

---

<div class="post-metadata">

**Author:** ![varadarajan](https://avatars.discourse-cdn.com/v4/letter/v/898d66/32.png) [@varadarajan](https://forum.opennebula.io/u/varadarajan)\
**Post date:** [May 3, 2016, 8:14am UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/4 "2016-05-03T08:14:49Z")

</div>

"For my ONe cloud, i went the first way, and it worked "

Could you elaborate on how you did this ?

---

<div class="post-metadata">

**Author:** ![Yenya](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/yenya/32/4624_2.png) [@Yenya](https://forum.opennebula.io/u/Yenya)\
**Post date:** [May 3, 2016, 9:01am UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/5 "2016-05-03T09:01:19Z")

</div>

I don’t remember exactly, but something like this:

- stop OpenNebula (especially oned)
- sqlite3 one.db .dump \> one.sqlite
- [sqlite2mysql.pl](http://sqlite2mysql.pl) \< one.sqlite \> one.mysql  
([sqlite2mysql.pl](http://sqlite2mysql.pl) taken from stackexchange or something like that - search for “SQLite to MySQL conversion”
- create an empty database on your MySQL server
- verify that you can log into it from the host oned runs at
- mysql -h host -u user -p password \< one.mysql
- edit oned.conf to reflect the new DB driver
- onedb fsck -S host -u user -p password
- rename one.db to something different just in case
- start oned
- profit!

---

<div class="post-metadata">

**Author:** ![varadarajan](https://avatars.discourse-cdn.com/v4/letter/v/898d66/32.png) [@varadarajan](https://forum.opennebula.io/u/varadarajan)\
**Post date:** [May 3, 2016, 1:11pm UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/6 "2016-05-03T13:11:53Z")

</div>

Thanks.

Suppose for a fresh install with Mysql as backend … How do you prevent the default backend from kicking in ?

---

<div class="post-metadata">

**Author:** ![Yenya](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/yenya/32/4624_2.png) [@Yenya](https://forum.opennebula.io/u/Yenya)\
**Post date:** [May 3, 2016, 2:15pm UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/7 "2016-05-03T14:15:09Z")

</div>

Comment it out in oned.conf?

---

<div class="post-metadata">

**Author:** ![jmelis](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jmelis/32/24_2.png) [@jmelis](https://forum.opennebula.io/u/jmelis)\
**Post date:** [May 9, 2016, 8:34am UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/8 "2016-05-09T08:34:47Z")

</div>

It is worth noting that in OpenNebula 5.0 there will be a native way to do this:

```auto
$ onedb sqlite2mysql --help
## USAGE
sqlite2mysql 
        Migrates a SQLite OpenNebula Database to MySQL
        valid options: backup

```

---

<div class="post-metadata">

**Author:** ![varadarajan](https://avatars.discourse-cdn.com/v4/letter/v/898d66/32.png) [@varadarajan](https://forum.opennebula.io/u/varadarajan)\
**Post date:** [May 9, 2016, 9:57am UTC](https://forum.opennebula.io/t/changing-database-from-sqlite-to-mysql/2169/9 "2016-05-09T09:57:51Z")

</div>

That will be great. It will be nice if you ask during install itself about the choice of DB like , sqlite , mysql , postgresql or whatever !
