Trying to migrate a database from MySQL to PostgreSQL. All the documentation I have read covers, in great detail, how
Convert the data as follows (do not use mysql2pgsql.perl):
Escape the quotes.
sed "s/\\\'/\'\'/g" climate-my.sql | sed "s/\\\r/\r/g" | sed "s/\\\n/\n/g" > escaped-my.sql
Replace the USE "climate"; with a search path and comment the comments:
sed "s/USE \"climate\";/SET search_path TO climate;/g" escaped-my.sql | sed "s/^\/\*/--/" > climate-pg.sql
Connect to the database.
sudo su - postgres
psql climate
Set the encoding (mysqldump ignores its encoding parameter) and then execute the script.
\encoding iso-8859-1
\i climate-pg.sql
This series of steps will probably not work for complex databases with many mixed types. However, it works for integers, varchars, and floats.
Since mysqldump included the primary keys when generating the INSERT statements, they will trump the table's automatic sequence. The sequences for all tables remained 1 upon inspection.
Using the ALTER SEQUENCE command will set them to whatever value is needed.
There is no need to prefix tables with the schema name. Use:
SET search_path TO climate;