3

I'm trying to setup ownCloud in a test lab. I somehow managed to create a 'owncloud' user (which is fine). The account has an empty password (I'm not sure how that happened), so I'm trying to set one:

MySQL and 'No Current User' after logging in as a user

For reasons that I don't understand (I'm not a database guru), the database is telling me there's no current user even though I logged in using the 'owncloud' test account.

Any ideas how to make MySQL behave as expected?

EDIT: I was wrong about the user 'owncloud'. It was not created though the ownCloud setup (I think I confused the server's name ('owncloud') with the user ('owncloud') because I expected it to be there).

New question: how in the world could I successfully log in under a non-existent user account?

2 Answers 2

3

The following result of the CURRENT_USER()

mysql> SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| @localhost     |
+----------------+
1 row in set (0.00 sec)

says that you're currently using the database as anonymous user. A freshly installed MySQL db has the following user entries in its mysql.user table:

mysql> SELECT user,host,password from mysql.user;
+------------------+-----------------+-------------------------------------------+
| user             | host            | password                                  |
+------------------+-----------------+-------------------------------------------+
| root             | localhost       | *........................................ |
| root             | xxxx            | *........................................ |
| root             | 127.0.0.1       | *........................................ |
| root             | ::1             | *........................................ |
|                  | localhost       |                                           |
|                  | xxxxx           |                                           |
| debian-sys-maint | localhost       | *........................................ |
+------------------+-----------------+-------------------------------------------+
7 rows in set (0.00 sec)

There are some root accounts (password-secured) and two anonymous accounts allowing a logon from localhost (the xxxxx entry is the machine's hostname).

If there's an entry in the user table lacking username and password, the following rule applies:

If the User value is blank, it matches any user name. If the user table row that matches an incoming connection has a blank user name, the user is considered to be an anonymous user with no name, not a user with the name that the client actually specified. This means that a blank user name is used for all further access checking for the duration of the connection (that is, during Stage 2).

(see the MySQL docs, "6.2.4. Access Control, Stage 1: Connection Verification")

In general, after installing MySQL, you should take notice of the following part of the documentation: "2.11.2. Securing the Initial MySQL Accounts".

1
  • Great, thanks tohuwawohu. So I'm clear: its a feature, not a security bug ;)
    – user207039
    Dec 30, 2013 at 16:25
0

You have an error in set password command. You have to specify set password for whom..The correct syntax is

SET PASSWORD FOR 'user-name-here'@'hostname-name-here' = PASSWORD('new-password-here');
1
  • Thanks maythux. According to SET PASSWORD Syntax: "With no FOR user clause, this statement sets the password for the current user." But I did try it with the FOR user clause and got the same result.
    – user207039
    Dec 30, 2013 at 8:35

You must log in to answer this question.