That's a big leap.
Recommend:
1. mysqldump to dump the table creations and data. Skip the "mysql" database.
2. Build 5.x with no data.
3. Add (now or later) the GRANTs you will need.
4. If you were using InnoDB, edit the dump to add commands to turn off/on foreign key checking.
5. mysql <dumpfile
6. Edit your source code for any reserved words that are new. Either rename the columns or add backtics (`) around them.
The above does not deal with character set issues. That's a bigger can of worms. You can possibly ignore it, but you will probably have a sloppy schema. Do you need any text other than Ascii (English)? If so, SHOW CREATE TABLE and let's discuss specific cases.
http://mysql.rjweb.org/doc.php/charcoll
may give you some clues of the future (if you need Internalization).
4.0.2 is really, really, antique. 5.0 in moderately antique. Why not 5.1 or even 5.5?