0

In a Fedora system, I need to convert the Owncloud's SQLite database into a MySQL/MariaDB database I started installing MySQL:

# systemctl enable mysqld
# systemctl start mysqld
$ mysql_secure_installation

then

$ mysql -u root -p
  CREATE USER 'owncloud_user'@'localhost' IDENTIFIED BY '12345';
  CREATE DATABASE IF NOT EXISTS owncloud;
  GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud_user'@'localhost' IDENTIFIED BY '12345';

and let's assume that owncloud_user's password is 12345 Now, from Owncloud 7.0 admin manual, entering

# php occ db:convert-type --all-apps mysql owncloud_user 127.0.0.1 owncloud

I have been prompted for:

What is the database password?

Database password? I only created a password for user owncloud_user, so I entered the password 12345 but I obtain error

[PDOException]                                                                                   
SQLSTATE[HY000] [1045] Access denied for user 'owncloud_user'@'localhost' (using password: YES)

Additional infos:

the machine has IPv6 enabled

MariaDB [(none)]> SELECT user, host FROM mysql.user;
+---------------+-----------+                                                                                                                                                             
| user          | host      |                                                                                                                                                             
+---------------+-----------+
| root          | 127.0.0.1 |
| root          | ::1       |
| owncloud_user | localhost |
| root          | localhost |
+---------------+-----------+
Germano Massullo
  • 193
  • 2
  • 4
  • 16
  • 1
    You refer to both '12345' and '123456' as password values. I presume that these are stand-ins for hte real password you use, and not the problem, but it is of course important that the password actually matches what you think it is. (If it really is that simple, then I'll make this an answer for the bounty). – mc0e Nov 16 '14 at 12:21
  • @mc0e `123456` was a mistype mistake during writing the question. $ mysql -u owncloud_user -p -t owncloud returns: Enter password: then ERROR 1045 (28000): Access denied for user 'owncloud_user'@'localhost' (using password: YES) – Germano Massullo Nov 16 '14 at 17:37

2 Answers2

1

Can you try specifying 127.0.0.1 and/or ::1 , like this

$ mysql -u root -p
  CREATE USER 'owncloud_user'@'127.0.0.1' IDENTIFIED BY '12345';
  CREATE USER 'owncloud_user'@'::1' IDENTIFIED BY '12345';
  CREATE DATABASE IF NOT EXISTS owncloud;
  GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud_user'@'127.0.0.1';
  GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud_user'@'::1';

The reason is this: http://dev.mysql.com/doc/refman/5.0/en/connecting.html

On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file.

Marki
  • 2,795
  • 3
  • 27
  • 45
  • I think this is likely the correct answer. When the connection command explicitly uses '-h localhost' it forces TCP. The incoming request is then considered to come from '127.0.0.1' rather than 'localhost' and looked up against the database accordingly. What I don't understand though is why a 'flush privileges' command would then fix matters? Or was the test different afterwards, perhaps leaving off the '-h localhost'? – mc0e Nov 17 '14 at 07:58
  • I tried for days all different types of localhost / local ip addresses, but that was not the problem – Germano Massullo Nov 25 '14 at 09:09
-1

You need to reload the privileges from the grant tables in the mysql database. You can do this with:

$ mysql -u root -p
  FLUSH PRIVILEGES;
  EXIT;
dgrimbergen
  • 243
  • 1
  • 2
  • 5
  • 4
    Incorrect. The grant statement does that for you. It's only necessary when you manipulate the 'mysql' database via sql statements. – mc0e Nov 16 '14 at 12:20
  • I deleted the database and the users. I noticed that in the Fedora wiki guide, the command `FLUSH PRIVILEGES` was missing after user creation. I entered it and now the conversion process starts correctly!!! – Germano Massullo Nov 17 '14 at 07:04
  • I'm glad this solved your problem @Caterpillar , but it's inconsistent with the question as you put it. IT suggests you did something to manipulate your access tables that's left out of what what you describe in the question. I don't think we should leave this as it is for others to read, and suggest that the question and/or the answer wants editing. – mc0e Nov 17 '14 at 07:48
  • @mc0e if you suggest me what I have to write in the question I will make some edits – Germano Massullo Nov 17 '14 at 07:51
  • @Caterpillar Were there other things you tried doing to the mysql.user or mysql.db tables in the course of trying to get things to work? – mc0e Nov 17 '14 at 07:52
  • @dgrimbergen please replace your MySQL code with the MySQL code in http://fedoraproject.org/wiki/OwnCloud – Germano Massullo Nov 17 '14 at 07:58
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/18719/discussion-between-mc0e-and-caterpillar). – mc0e Nov 17 '14 at 07:58