To "backup" and "restore" i recommend dumping rather than file copying.
To dump a database you can use the integrated "mysqldump" utility BEFORE removing mysql 3.23. You would simply issue
Code:
# dump [database name] > ~/db1.sql
You do that with all your databases (if you issue "mysqldump" without a database paramater it will dump all databases, including the "mysql" database which might not have the same structure in v4.x). Then, you remove v3.23, install v4.0 (v4.1 is still dev so its your choice) and atfer you get a new v4 working, open up the mysql client as root and import your databases from the files you dumped like this:
Code:
# mysql -p
create database [dumped database name];
use [dumped database name];
source ~/db1.sql;
You repeat the "create ... use .. source" steps for each dumped db.
This is a safe way to export import data. Dumping using "mysqldump" outputs pure SQL code which is sourced with no problems by future clients as oposed to copying the database files from the old v3.23 ...
Hope this helped. Cheers.