Bug #42028 mysql_upgrade fails with "Unknown system variable 'have_csv'"
Submitted: 11 Jan 2009 10:07 Modified: 8 Dec 2016 14:53
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Installing Severity:S2 (Serious)
Version:5.1.30 OS:Microsoft Windows (Vista 32 bit)
Assigned to: CPU Architecture:Any
Tags: qc
Triage: Triaged: D5 (Feature request)

[11 Jan 2009 10:07] Peter Laursen
Description:
Mysql_upgrade fails after upgrade from 5.1.29.

Port is correct.  Also mysql_upgrade on 5.0.67 and 6.0.8 wirks fine (on their respective ports)

How to repeat:
C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql_upgrade port=3308 -uroot -p
Enter password: ********
Looking for 'mysql.exe' as: C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.ex
e
Looking for 'mysqlcheck.exe' as: C:\Program Files\MySQL\MySQL Server 5.1\bin\mys
qlcheck.exe
Running 'mysqlcheck'...
<all tables returned OK>

Running 'mysql_fix_privilege_tables'...
ERROR 1193 (HY000) at line 69: Unknown system variable 'have_csv'
ERROR 1064 (42000) at line 71: You have an error in your SQL syntax; check the m
anual that corresponds to your MySQL server version for the right syntax to use
near 'NULL' at line 1
ERROR 1243 (HY000) at line 72: Unknown prepared statement handler (stmt) given t
o EXECUTE
ERROR 1243 (HY000) at line 73: Unknown prepared statement handler (stmt) given t
o DEALLOCATE PREPARE
ERROR 1193 (HY000) at line 77: Unknown system variable 'have_csv'
ERROR 1064 (42000) at line 79: You have an error in your SQL syntax; check the m
anual that corresponds to your MySQL server version for the right syntax to use
near 'NULL' at line 1
ERROR 1243 (HY000) at line 80: Unknown prepared statement handler (stmt) given t
o EXECUTE
ERROR 1243 (HY000) at line 81: Unknown prepared statement handler (stmt) given t
o DEALLOCATE PREPARE
FATAL ERROR: Upgrade failed

C:\Program Files\MySQL\MySQL Server 5.1\bin>

Suggested fix:
No idea. Not sure if this is an issue specific for my system/installation or not! 

I mark as "S2", but that will of course depend on if this is a general issue or not!
[11 Jan 2009 17:18] Valeriy Kravchuk
Thank you for a problem report. What exact package of 5.1.30 you had downloaded? Can you give the URL, please.
[11 Jan 2009 17:53] Peter Laursen
I normallly download from ftp://mirrors.dotsrc.org/mysql/Downloads/ . I have a *FTP-watcher* running as a background process and this is the MySQL mirror I am *watching* with this tool.  So 99.5% sure that this is the link is this:

ftp://mirrors.dotsrc.org/mysql/Downloads/MySQL-5.1/mysql-5.1.30-win32.zip
[12 Jan 2009 12:58] Peter Laursen
I found out! I connect to my 5.0.67 instance running on port 3306!

this is incorrect command syntax: 
* mysql_upgrade port=3308 -uroot -p

these work
* mysql_upgrade --port=3308 -uroot -p
* mysql_upgrade P3308 -uroot -p

But I think first invalid variation should be rejected as incorrect syntax for mysql_upgrade program! Compare

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql port=3308 -uroot -p
Enter password: ********
ERROR 1049 (42000): Unknown database 'port=3308'
[12 Jan 2009 13:04] Peter Laursen
BTW: the good question is now if I have done damage to my 5.0.67 installation ?!

So in conclusion the should be reclassified to a (still quite serious) client bug in mysql_upgrade.  Database parameter makes no sense for this program.  And you will risk to execute *fix_privileges* against the wrong server!
[12 Jan 2009 20:26] Peter Laursen
I think:

(just repeating)
1) syntax checking in mysql_upgrade should be more strict.  This is a critical operation and the slightest inaccuracy in the command syntax should return an error and do nothing.

(but even one more consideration)
2) as default mysql_upgrade should look up the *fix_privileges* script belonging to the version that was logged on to! (and also the 'mysqlcheck' and 'mysql' insatnces belonging to the version logged on to).  The 'basedir' variable exists and can be used to identify the proper files!

(ultimate safety)
3) Maybe even the script should check for server versions and abort if it is not the version matcing the script!

Since it is so easy (on Windows at least) to have several server instances installed simultaneously and as people like me (I have 6 official MySQL server binaries + 2 special and 'patched' servers installed to use different port and service names) do this for testing applications with all main server versions the upgrade procedure should be more safe!
[14 Jan 2009 19:51] Sveta Smirnova
Thank you for  the reasonable feature request.
[14 Jan 2009 19:56] Peter Laursen
I think it would be *plain simple* to implement this pseudocode

IF substr(version ....) = 5.1.30 then <execute script>
ELSE printout "this script is not fit for this server version" and EXIT

It can be done in the mysql_upgrade binary of in the *fix_privileges* script.  The latter is preferable.

It is not a *feature request* - it is a *bug*.. We are living in the 21th century!
[29 Sep 2009 15:04] Susanne Ebrecht
B ug #47710 is set as duplicate of this bug here
[11 Jun 2010 8:54] C├ęsar Casado
Hi,

I got this error when upgrade from 5.0.91 to 5.1.47 in WinXP
On mysql_upgrade, first: table mysql.general_log doesn't exist.
and later when try to fix it: Running 'mysql_fix_privilege_tables'...
ERROR 1193 (HY000) at line 69: Unknown system variable 'have_csv'
...

Then i check for mysql server version.. and still appearing 5.0.91.

The msi installed as service mysqld-nt.exe. I manually remove that service and install again with mysqld.exe.

Now version appears correctly and mysql_upgrade worked fine.

Regards
[4 Oct 2010 13:16] Susanne Ebrecht
Bug #46017 is a duplicate of this bug here.
[8 Nov 2010 10:43] Shane Bester
the first problem, where mysql_upgrade didn't complain about the extra "port=3308" on the command line, is the same as what happened in bug #45059
[7 Dec 2012 17:28] Adam Scott
be sure you are running the correct version of mysql_upgrade against your running database

mysql_upgrade --help will show Distrib {version} where {version } is the version you are upgrading _to_

do a 
   which mysql_upgrade

to see which mysql_upgrade command is executed in case you have several installed
[8 Dec 2016 14:53] Yngve Svendsen
Posted by developer:
 
Closing since this is related to an EOL (no longer supported version) of MySQL Server.