core icon indicating copy to clipboard operation
core copied to clipboard

MySQL setup when oc_admin exists already

Open RandolfCarter opened this issue 14 years ago • 17 comments

The current database procedure seems to do different things, depending on what kind of user is entered:

If an "unprivileged" user is entered, and the database exists already, everything seems to be set up correctly.

If a privileged user is entered however, then the setup will try to create a user called 'oc_admin' (and if no database with the given name exists, it will be created and oc_admin will be granted rights on it).

There's a problem with that latter approach: oc_admin can exist already; if it does, setup will result in an error message "MDB2 Error: connect failed: _doConnect: [Error message: unable to establish a connection] [Native code: 0] "

RandolfCarter avatar Oct 26 '12 10:10 RandolfCarter

@icewind1991 @butonic can one of you please have a look? You know MDB2! THX

DeepDiver1975 avatar Nov 15 '12 23:11 DeepDiver1975

@DeepDiver1975 It's not MDB2-related, it's installation flow. When MySQL 'root' account is used and the name for owncloud admin is set to 'Dummy'. ownCloud creates DB user oc_Dummy and grants permissions on newly created database to this user.

If DB user oc_Dummy exists PRIOR to OC installation wrong credentials are used by ownCloud and installation fails.

Most easiest way to reproduce:

  1. Install 1st ownCloud instance with MySQL using privileged (root) Mysql user. Set ownCloud admin name to 'admin'. other settings are not essential
  2. Repeat step 1. Installation fails.

Reproducible both with master and stable45

VicDeo avatar Dec 13 '12 21:12 VicDeo

it's fixed in master with #1148 , there is a warning now:

MySQL user 'oc_Admin'@'localhost' exists already. Drop this user from MySQL

Thus it's still not possible to install 2 ownCloud instances using privileged MySQL account using the same username for ownCloud admin account.

Not backported to stable45. @DeepDiver1975 can we close this issue?

VicDeo avatar Feb 15 '13 21:02 VicDeo

I don't think this issue should be closed. I bet there are many other use cases where one would want to have several ownCloud instances with the same admin username - for debugging different versions it's a PITA, but that's another issue. Having an error message explaining the error is a step forward, although "Drop this user from MySQL" is a bulldozer solution ;)

tanghus avatar Feb 15 '13 22:02 tanghus

imho OC should not create users in mysql at all by default. it should ask at least during the installation, if the current "privileged" user should be used or if it should create one. And if OC is creating one, it should ask for the username.

benjamin-garn avatar Mar 08 '13 09:03 benjamin-garn

with 5.0 RC3 I got the following (mysql):

  • 1st installation OK
  • reinstall: KO drop this user message
  • drop user, delete from mysql.user where user=admin, flush privileges, drop database
  • got back to MDB2 Error: connect failed: _doConnect

riso avatar Mar 08 '13 22:03 riso

@riso

You need to use

Drop user USER@localhost Drop user USER@'%'

(USER is the oc user name)

BernhardPosselt avatar Mar 08 '13 22:03 BernhardPosselt

when i dropped both the users it still failed, but on the next try i dropped both the users and deleted config.php and it worked.

My (very vague) suspect is that for some reason it had an old hashed password. I always used the same password though, but I guess that the salt changes. Do you think that is possible?

riso avatar Mar 09 '13 11:03 riso

I think the main panel is misleading. The lower part 'Configure the database MySQL will be used' should clearly state that the user here needs to be a MySQL-admin with the right to add users and to grant permissions. As soon as I figured this out the installation ran without problems.

ewbrager avatar May 06 '13 08:05 ewbrager

@ewbrager

The lower part 'Configure the database MySQL will be used' should clearly state that the user here needs to be a MySQL-admin with the right to add users and to grant permissions.

In general he shouldn't. Alternatively he can have full access on the specified database and database should exist already

VicDeo avatar May 06 '13 15:05 VicDeo

I’m closing this issue because it has been inactive for a few months. This probably means that the issue is not reproducible or it has been fixed in a newer version.

Please reopen if the error still persists with the latest stable version (currently ownCloud 5.0.9) and then please use the issue template. You an also contribute directly by providing a patch – see the developer manual. :)

Thank you!

jancborchardt avatar Aug 07 '13 14:08 jancborchardt

This is still an issue. It becomes a problem when you have development and production environment. You can't test both without fiddling with the users.

chasefriedman avatar Apr 01 '14 19:04 chasefriedman

I just got this issue with OC6 installation/upgrade using Mysql

blurmonk avatar Apr 02 '14 21:04 blurmonk

The only way to fix that is to create a different account (maybe oc_admin1) in this case. Because we're not able to find out the password for the former one and can not override it as it may be in use. Is it a acceptable approach to add a sequential number at the end?

visit1985 avatar Jul 28 '14 18:07 visit1985

On mysql table, do this, works for me.

Drop user USER@localhost Drop user USER@'%'

(USER is the oc user name)

kamihouse avatar Aug 09 '14 23:08 kamihouse

@craigpg This is in the ownCloud 5 milestone and the last open one in the closed milestone. Maybe have a look and triage.

MorrisJobke avatar Sep 16 '14 08:09 MorrisJobke

This is fixed in the master branch and will be released together with ownCloud 8.

LukasReschke avatar Oct 30 '14 13:10 LukasReschke