# mysql_upgrade appears worthless -- broken



## Chris_H (Jul 17, 2013)

Greetings,

 Afetr upgrading MySQL server from 5.5.30, to 5.5.32. I followed the instruction at the end, that indicated running mysql_upgrade(1). Which helpfully emitted:

```
mysql_upgrade -u root
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed
```
Cool! Looks like a successful upgrade.  Ahem, WTF! Could the output be any less useful? What a WOT! Too bad Oracle had to "improve" MySQL. I think I liked it better when MySQL-AB owned it. Well just checked the database(s). Everything works. I guess it just won't reflect the _actual_ version.

Anybody else run into this problem?

Thank you for all your time, and consideration.

--chris


----------



## cpm@ (Jul 17, 2013)

You may also need to stop the MySQL daemon before executing mysql_upgrade(1) and start it again when finished.

Also see as reference.

EDIT: The mysql_upgrade(1) man page is based on the MySQL reference manual, until here everything is clear, however it needs some corrections as you can see in the comments of the bottom. 

Please, file a PR to the freebsd-doc mailing list to fix the man page.


----------



## Chris_H (Jul 17, 2013)

Greetings, and thank you for the reply.

Well, while I haven't read the link yet. I _did_ stop the service(8), prior to performing the upgrade. I read the info presented after the upgrade, and fired off mysql_upgrade(1). Which emitted that nice ERROR. So, I popped open the man page for mysql_upgrade(1), which informed me that I needed to have the service(8) running first:

```
# service mysql-server start
# mysql_upgrade -u root --verbose

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed

#_
```
So, dunno. I'll have a look at the link you provided.

Thanks again, for taking the time to respond, @cpu82.

--chris


----------



## Chris_H (Jul 17, 2013)

Greetings @cpu82,

 The link you gave me, was the same page as the man page that mysql_upgrade(1) installs. _But_, there was a comment, by a user at the very bottom of the page, that got me thinking. Comment: `mysql_upgrade -u root -p`. *Nowhere* in the info at the end of the install, nor anywhere in the man(1) page, does it _suggest_ you _should_ use root's logon to process the upgrade. I _did_ use `-u root`, and even `--verbose`. But all it emitted was ERROR. Not the usual password error received when you omit a password. So. Turns out:

```
# mysql_upgrade -u root -p --verbose
Enter Password:
```
gets it.

So +1 to you. 

I think this should be _emphasized_ in the mysql_upgrade(1) man page, or presented/added with the other info, at the end of the upgrade/install.

Thanks again.

--chris


----------



## SirDice (Jul 17, 2013)

As far as I know you only need to run it if you change versions (5.0 -> 5.5 for example), not for a minor update.


----------



## ShelLuser (Jul 17, 2013)

Chris_H said:
			
		

> I think this should be _emphasized_ in the mysql_upgrade(1) man page, or presented/added with the other info, at the end of the upgrade/install.


I don't quite agree here because what you're describing is behaviour which even pre-dates the Sun acquisition of MySQL.

Please keep in mind that this behaviour isn't something specific for mysql_upgrade but is common for all MySQL utilities. From the mysql command itself to mysqldump, mysqlcheck and mysqladmin. If you use a MySQL account which has a password assigned to it you need to specify the password parameter.

What does seem out of place though is that the mysql_upgrade manualpage doesn't mention the available --password or -p option.


----------



## Chris_H (Jul 17, 2013)

ShelLuser said:
			
		

> I don't quite agree here because what you're describing is behaviour which even pre-dates the Sun acquisition of MySQL.
> 
> Please keep in mind that this behaviour isn't something specific for mysql_upgrade but is common for all MySQL utilities. From the mysql command itself to mysqldump, mysqlcheck and mysqladmin. If you use a MySQL account which has a password assigned to it you need to specify the password parameter.
> 
> What does seem out of place though is that the mysql_upgrade manualpage doesn't mention the available --password or -p option.



Greetings @ShelLuser,

 We agree that it is not unusual to require user, and password to perform many maintenance tasks. My gripe is that failure provides _no_ clues -- it is inconsistent with MySQL itself. E.g.:

```
# mysql -u root add
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
```
as opposed to:

```
# mysql_upgrade -u root --verbose

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed
```
_Zero_ indication that the _user_ caused the fail, not the _upgrade process_.
I hope I am a little clearer this time. 

Thanks for your response.

--chris


----------



## Chris_H (Jul 17, 2013)

cpu82 said:
			
		

> You may also need to stop the MySQL daemon before executing mysql_upgrade(1)() and start it again when finished.
> 
> Also see as reference.
> 
> ...


Greetings @cpu82, and thank you for your reply.

Will do. Consider it done. 

--chris


----------



## wblock@ (Jul 17, 2013)

MySQL is a port, so a PR should go to ports.  But really, it sounds like an upstream bug that should be logged in their bug system and fixed there.


----------



## Chris_H (Jul 17, 2013)

100% agree. But I _did_ post my experience to freebsd-doc@. At least users that get "bitten", will have a better "clue". 

--chris


----------



## cpm@ (Jul 18, 2013)

Chris_H said:
			
		

> 100% agree. But I _did_ post my experience to freebsd-doc@. At least users that get "bitten", will have a better "clue".
> 
> --chris



Sorry for my cluelessness, read this message. @wblock@, thanks for the pointer.

Good news: ports/180624: databases/mysql55-server: mysql_upgrade man, and upgrade/install info missing mandatory information.


----------



## Chris_H (Jul 19, 2013)

*Yeah @cpu82!* I got a _real_ scolding for that -- THANKS! O.K. I _did_ get a sharp message about it. But it's all good.  I made the pr(1). So I think it'll be fine for others now. 

All the best.

--chris


----------



## PariThusnavis (Feb 20, 2014)

Hi,

 I got an workaround for this similar type of error that I faced.


```
# mysql_upgrade -u root --verbose

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed
```

This is not the user error. Its just the MySQL client which is in the older version trying to connect with old password formats. 
Solution:
Move to the newly installed base_directory/bin and run the `mysqlupgrade`.
`/BASE_DIR/bin#./mysql_upgrade -uroot -p -S<socket>`

My analysis:
When I checked mysql_upgrade, it runs the below statements.


```
mysqlcheck --all-databases --check-upgrade --auto-repair
mysql < fix_priv_tables
```
So I ran mysqlcheck manually with user/password (All privileges- root) and I got the old client error.

I checked the PATH and the mysqlcheck ran and I found another MySQL client installation path. So the clients were mistaken when I ran mysql_upgrade.


----------

