ERROR 1231 (42000) with sql_mode when trying to import a sql dump in MySQL Workbench - mysql

I am trying to import a dump of a database to my localhost in MySQL Workbench.
At the moment of trying to import a dump of MySQL version 5.7 to a 8.0.14 version, I get this error:
ERROR 1231 (42000) at line 198: Variable sql_mode can't be set to the value of NO_AUTO_CREATE_USER
Operation failed with exitcode 1
The problem is that the dump has a size of 4GB and I can't open it beacause my PC freezes. Is there a form of remove this line or solve this problem?

You seem to have hit this MySQL 8.0 bug. The bug page says it's fixed in 8.0.13, but since you are using 8.0.14 and still meeting the problem, this might not be the case...
It also suggest a workaround : replace all instances of ,NO_AUTO_CREATE_USER with nothing. If you are not able to open the file with a text editor because it is too big, you can use Perl to update the file in place with a regular expression, like:
perl -pi -e 's/,NO_AUTO_CREATE_USER//g' file
Flags explanation:
-e causes the Perl code to be executed
-p means : execute the code for each file line
-i means : edit the file in-place

Related

MySQL's net_read_timeout variable is reset to the intial value after a timeout during query

Background
I use the following code to import a SQL file into a MySQL database which worked for the A.sql file with a size of 23.4 MB:
mysql myDataBase < A.sql
Then, I have a second file, B.sql which is 11.7 MB. When I use the same code in the terminal, I get this error message:
ERROR 2013 (HY000) at line 41: Lost connection to MySQL server during query
Research and actions taken to solve the problem
I did my research, and the following MySQL's webpage suggests that I have to increase the value of net_read_timeout:
https://dev.mysql.com/doc/refman/5.7/en/error-lost-connection.html
I used the following code at the MySQL prompt to change the variable from the 30s to 60s:
mysql> set global net_read_timeout = 60;
I check if the variable's value changed:
mysql> show global variables like 'net_read_timeout';
It has changed to 60s.
then I exit from MySQL again type mysql at the terminal (as root always in this case) and check again if MySQL has held net_read_timeout = 60 s. It held the value.
Now I exit MySQL again and at the linux terminal I type the following to import B.sql into myDataBase:
mysql myDataBase < B.sql
and I get this error message:
ERROR 2013 (HY000) at line 41: Lost connection to MySQL server during query
It doesn't take more than a few seconds to get this error message, definitely not 30s. Nevertheless, I go back to check the value of net_read_time out.
I start MySQL as root and type:
mysql> show global variables like 'net_read_timeout';
I see that net_read_timeout is back to 30s.
I tried to go to MySQL configuration files to change this variable manually:
I use Ubuntu LTS 20.04 (server), and I find the configuration files in the following path:
/etc/mysql
which included the following files and directories:
conf.d debian-start debian.cnf my.cnf my.cnf.fallback mysql.cnf mysql.conf.d
Searching all of these files, I couldn't find the net_read_timeout variable. Also, I have noticed there wasn't much inside these files. There are other suggested variables to change their values for resolving this problem, for example, connect_timeout, and they are not in those configuration files.
Some of the configuration file names are repeated in subfolders, and this is a question about which one is the configuration file that MySQL is using.
Summary and the main problem
The net_read_timeout is reset to the initial value upon the time out during the query.

PHPMYADMIN error while importing big sql dump

I am trying to import a big SQL dump into my mysql database but I got an error which the following.
Via PHPMYADMIN interface I didn't manage to import it, it says too voluminous.
So I tried with command line: mysql -uroot -p dbsnp < SNP_HGVS.sql but I got this error:
ERROR: ASCII '\0' appeared in the statement, but this is not allowed 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:d�L'.`
Do you know how to resolve this issue?
Many thanks.
As per clarification question and comments:
The source SQL dump was not correctly setup and formatted for MySQL. Re-dumping the data with the correct MySQL configuration/format resolves the issue.
It seems to me the character of dump file is not UTF-8.As per the error you need to --binary-mode on. Please check the link: [Enable binary mode while restoring a Database from an SQL dump

import large MySQL Database - PHPMyAdmin error

Trying to import a very large database file.
Windows Apache PhpMyAdmin.
USE test;
source somefil.sql;
I get a syntax error:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source somefil.sql' at line 1 "
There is no such command in mysql server as source. This command is specific to mysql own command line client, which is also named mysql, therefore it is not available in phpmyadmin.
Copy-paste the contents of the sql file into the command window of phpmyadmin and execute its contents directly from there. You may have to increase the php max execution time parameter, if the import file is truly big.
However, I would use the command line client to execute a really big sql file because phpmyadmin is not suitable for that.
to restor backup of my datebase I use command like that
from your os command promt :
mysql -u youruser -p yourdatabasename < yourfilewithfullpath.sql
Actually source command is used from command prompt so Use below steps-
Go to command prompt-
connect mysql
now use below command-
source d:/backup/somefil.sql;

MySQL server has gone away exception while importing a huge database

I am trying to import a new database from an sql dump file with size above 2.6 GB. To do this I am running the below command to import the database from the sql file.
mysql -u root -proot --database=test_db < test_db.sql 
and the error response I got at this time.
ERROR 2006 (HY000) at line 51: MySQL server has gone away
I think the problem over here is some timeout is happening somewhere. Only one table has creatd in the new database from the sql file. Is there anyway to overcome this issue?
Try changing the max_allowed_packet setting to a larger value in the server.
Open "my.ini/cnf", located in your MySQL installation folder, and under [mysqld] section change "max_allowed_packet = 64M" and don't forget to restart the server. You can check the value by executing:
SHOW VARIABLES LIKE 'max_allowed_packet';
Refer: http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

Importing using MySQL WorkBench... error ERROR 1046 (3D000)

Scenario: building a RoR enviroment locally for development. Production is on EngineYard / GitHub. All now working ok, except DB isn't importing.
I have a .sql file that i've taken from my prod EY site. Now i need to import it to my MySQL locally. I'm using Workbench (as i'm new to this), but getting error below.
Please help?
08:07:43 Restoring /home/james/Downloads/Futology.sql Running: mysql
--defaults-extra-file="/tmp/tmpAVeE58/extraparams.cnf" --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments < "/home/james/Downloads/Futology.sql" ERROR 1046 (3D000) at line 22: No database selected
Operation failed with exitcode 1 08:07:43 Import of
/home/james/Downloads/Futology.sql has finished with 1 errors
Workbench doesn't know the database (schema) you want to use.
In workbench, when using Data Import/Restore, just below where you choose the file to import, it asks "Default Schema to be Imported To"
Just choose the database (schema) you want it to use from the dropdown titled Default Target Schema. If you don't have a database (schema) already, you can create it with the "New" button.
This is confusing because MySQL generally seems to use the term database but Workbench uses schema. They mean the same thing for most purposes. MySQL 'create schema' and 'create database' - Is there any difference
Not used Workbench too much however it's easy enough to do from command line have a look at this (below phpMyAdmin instructions)
The command you're after is:
mysql -u #username# -p #database# < #dump_file#
Simply by choosing your target schema
As I circled in above image
Similar to brynn's answer, simply modify your SQL file and insert the following line at the very top:
use yourdatabasename
Replacing yourdatabasename with the database into which you are trying to import. Also, this database should already be created (albeit empty) before you import into it.
Here's another option that worked for me. I'm using MySQL 5.5 on a VM I set up for importing a large MySQL .sql dump that contained: 1). a create table statement 2). insert statements for inserting a large amount of data into the table.
at the MySQL command line client prompt type:
use yourdatabasename
source d:\yourpath\yourfilename.sql
for more info on the 'source' and other commands, enter ? at the prompt.
The above command line is correct. I found I have to do this when importing .sql files from older versions of MySQL. I also found I had to edit the .sql file (top of the file) and set the db name to be the same as the blank db you create before doing the import.