I would like to take a dump from Mysql 8.0.11 and restore it into 5.7.27.
When I tried to restore it I got the error:
ERROR 1273 (HY000) at line 25: Unknown collation: 'utf8mb4_0900_ai_ci'
Then I tried to use the compatible flag to make it easier on an older MySQL DB.
mysqldump --compatible=mysql4 --add-drop-table -u r00t -h xxx.eu-north-1.rds.amazonaws.com -p radius_db > ~/radius.sql
But that doesn't seem to work either:
mysqldump: Couldn't execute '/*!40100 SET ##SQL_MODE='MYSQL40' */':
Variable 'sql_mode' can't be set to the value of 'MYSQL40' (1231)
Any advice would be appreciated.
Simply put, use as a DEFAULT "utf8" and as COLLATE "utf8_general_ci".
One way to solve your problem is to change in your import .sql-Files from
"utf8mb4" to "utf8"
and "utf8mb4_0900_ai_ci" (or something else) to "utf8_general_ci"
Hint: Don't forget to backup your files just in case ;-)
Go to your (.sql) import files and do these changes.
From:
ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8_general_ci;
to:
ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
Reimport again.
You can use the next code to move your database from mysql 8.x to mysql 5.x.
mysqldump db > db.sql
sed -i s/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g db.sql
mysql db < db.sql
db is your database name
Related
I have 29GB magento db .sql file that need to be imported into mysql database, I am using Ubuntu 22.04 operating system
I import into database using command line as below
mysql -u root -p
mysql > USE magento_project1
mysql > source db_dump.sql
The import seems to be working fine at first, but after a few hours of importing error as below comes out
ERROR at line 44259: ASCII '\0' appeard in the statement, but this is not alllowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: '
Attached the image of the error
I noticed the query stopped when at the part it need to insert data into sales_order_payment table
I have try
rename the db_dump.sql file to db_dump.sql.gz
based on solution given here
import using command mysql -u root -p -f -D database_name < db_dump.sql.gz
when create database, create charset as utf8mb4, collation utf8mb4_general_ci
import using command mysql -u root -p -h localhost -D database_name --binary-mode -o < db_dump.sql
based on solution given here
When i write command file db_dump.sql.gz I get the result as below
db_dump.sql.gz: ASCII text, with very long lines (37268)
My ubuntu is already sudo apt-update and sudo apt-upgrade with mysql, php, nginx and elasticsearch installed and enabled
But none of the solution above fix the issue I am having
Able to fix the issue by dumping new database from magento cloud using command below
magento-cloud db:dump
0 -> Staging -> 0 ( database )
then import the db into local using command below
mysql -u root -p -f -D local_db < dumped_db.sql
Not sure what cause the error above on the first place, might be the db corrupted somewhere during transfer between pendrive ?
I need to convert a MyISAM latin 1 DB into a MyISAM utf8 db
following another question I exported my DB without any encoding specification
mysqldump -uroot -p --skip-opt --set-charset --skip-set-charset mydb > mydb_utf8.sql
changed my DB to default charset utf8
now I need to specify on import that i want MyISAM tables ( default setting is InnoDB )
mysql -uroot -p --default-character-set=utf8 --default-storage-engine=MyISAM mydb < mydb_utf8.sql
--default-storage-engine=MyISAM give me this error "mysql: unknown variable 'default-storage-engine=MyISAM'"
--default-storage-engine looks like its a mysqld startup option not a mysql start option..
Open your SQL file with a text editor and on the top
SET default_storage_engine=MyISAM;
I have a VM that I'll be installing mysql server on. I have a dump file that I need to import into mysql. The first line says this:
-- MySQL dump 10.13 Distrib 5.6.20, for linux-glibc2.5 (x86_64)
The file already has databases and tables, along with the structure and data.
grep -i 'current database' db_dump.txt
-- Current Database: `db1`
-- Current Database: `db2`
-- Current Database: `db3`
grep -i 'data for table' db_dump.txt
-- Dumping data for table `TABLE1`
-- Dumping data for table `TABLE2`
-- Dumping data for table `TABLE3`
As you can see, its a .txt file and this is partly where my confusion is coming in. Much of what I have read is that in order to import a text file you must already have the database's and tables created. However they are already defined in the file. So that lead me to running a command such as this:
mysql -u <user> -p < filename.dump
But some of the documentation says you must have a .sql file in order to do this. So can I just rename my .txt file to .sql or just import as is? What would the command look like? I am really a noob when it comes to MySQL so any guidance is much appreciated.
You command is correct. The extension of the filename is not important. It is what's inside that matters.
Oh! There is actually one thing that needs to change:
mysql -u<username> -p database_name < filename.dump
The database name should be the last part of the command and the username needs to go after -u, so if you are the root user you should type:
mysql -uroot -p database_name < filename.dump
I'm using mysqldump to dump my database that contains UTF8MB4 columns with UTF8MB4 data. When I import this .sql file into a new database with UTF8MB4 support, all UTF8MB4 characters are converted into ????. Anybody got a clue about how to make MySQL and import work with UTF8MB4?
You should specify the character set with --default-character-set=utf8mb4 option when using mysqldump.
$ mysqldump --default-character-set=utf8mb4 -uusername -p database > dump.sql
Since MySQL 8.0 default charset for mysqldump is utf8mb4, so the problem should not appear anymore.
However in MySQL 5.7 default charset for mysqldump is utf8, so there you should explicitly change it as in Henridv answer (--default-character-set=utf8mb4).
At shell command prompt:
mysqladmin -u"username" -p"password" --default-character-set=utf8 CREATE my_db_schema
--default-character-set=utf8 seems to have no effect and I don't understand why.
Database gets created, but character set is latin1 with collation latin1_swedish_ci.
I found this question, which would seem to be the same issue, but even when I tried a non-root user as the selected answer suggested, I get identical behavior:
MySQL connection character set problems
(I'm using Windows and MariaDB if that makes any difference)
I have tried these mysqladmin.exe clients:
MariaDB 5.3.2 for Win32 (ia32) with default character set latin1 (no .ini)
MySQL 5.0.77 for linux-gnu (i686) with default character set utf8
In both cases, --default-character-set=utf8 or --default-character-set=latin1 do NOT override the MySQL server's .ini/.cnf settings.
As a workaround I'd suggest running:
echo "CREATE DATABASE my_db_schema DEFAULT CHARACTER SET utf8" | mysql -uusername -ppassword
--default-character-set=utf8 seems to have no effect and I don't understand why.
Database gets created, but character set is latin1 with collation latin1_swedish_ci.
This options does not influence the character of a datatabase, table or column when they are created.
The default-character-set is the character set of the connection to the server -- it ensures values you select from the database come through to the client with the correct encoding for display.
On the surface I'd say this appears to be a mysqladmin bug. I would let the MariaDB devs know about it.
http://kb.askmonty.org/en/reporting-bugs has general instructions about reporting bugs (ignore the bit about using the mysqlbug script, since it is not available on Windows).
P.S. And if the bug exists in MariaDB it likely also exists in MySQL.