Import database dump with size of 20GB - mysql

I have a mysql database dump with 25GB of size
i use mysql 8 to import this dump
[root#hotsing] mysql -V
mysql Ver 8.0.15 for Linux on x86_64 (MySQL Community Server - GPL)
I run this command mysql -u root -p mydatabase < MySQLDump.sql
During import, this error message is show and the operation is failed
ERROR 1231 (42000) at line 22715: Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'
this is my sql mode
mysql> SELECT ##sql_mode;
+-----------------------------------------------------------------------------------------------------------------------+
| ##sql_mode |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
how i can resolve this , it is error from the dump or misconfiguration of mysql ? or the version of current mysql and the version of the database dump ?
thank You

Related

mysql 1290: have set "secure_file_priv" and used absolute path

System: Centos
Vesion:
Server version: 5.5.56-log Source distribution
What I did:
Have set the secure_file_priv in my /etc/my.cnf
mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+---------------+
| Variable_name | Value |
+------------------+---------------+
| secure_file_priv | /target_file |
+------------------+---------------+
Have restarted myssql service by service mysql restart, and inaddition I have restart the server/machine too
and I set chmod 777 /target_file
But I still get
>> select * from mytable into outfile '/target_file/config';
>> ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
Did I miss something?

mysqlimport from --secure-file-priv folder, but still got error

I had set --secure-file-priv as following:
mysql> show variables like '%secure%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | E:\test\ |
+--------------------------+----------+
but I got an error like this:
D:\Tool\mysql-5.7.17-win32\bin>mysqlimport -u root -p my_test tb < e:test/new/outfile.sql
Enter password:
mysqlimport: Error: 1290, The MySQL server is running with the --secure-file-priv option so it cannot execute this statement, when using table: tb
Another error:
D:\Tool\mysql-5.7.17-win32\bin>mysqlimport -u root -p my_test tb < e:test\new\outfile.sql
Enter password:
mysqlimport: Error: 1290, The MySQL server is running with the --secure-file-priv option so it cannot execute this statement, when using table: tb
what should I do to tackle this?
The fact is that in my.ini you did not specify the correct directory
Secure File Priv.
secure-file-priv="F:/directory"

importing a csv file into mysql from the command line using mysqlimport command

How to import a csv file into mysql from the command line using mysqlimport command, so thats without going into mysql.?
I am trying to use this answer here
to import a csv file into mysql from the command line
root#678cf3cd1587:/home# mysqlimport --columns='head -n 1 discounts.csv' --ignore-lines=1 temp discounts.csv -u root -p
Enter password:
mysqlimport: Error: 1064, 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 '-n 1 discounts.csv)' at line 1, when using table: discounts
root#678cf3cd1587:/home#
But I cannot get it to work can anyone advise what I am doing wrong?
this is what my file looks like
root#678cf3cd1587:/var/lib/mysql-files# cat discounts.csv
id,title,expired_date,amount
1,"1Spring Break ",20140401,20
2,"2Spring Break ",20140401,20
3,"3Spring Break ",20140401,20
4,"3Spring Break ",20140401,20
5,"3Spring Break ",20140401,20
6,"3Spring Break ",20140401,20
7,"3Spring Break ",20140401,20
And this is what my mysql looks like:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| temp |
+--------------------+
5 rows in set (0.00 sec)
mysql> use temp
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql>
NOTE I am running mysql in a docker container which I can give more details on if required
There is duplicates of this question but I think mine is specific.
EDIT1
I had tried the different single-quote ' double-quote " and backtick `. although the back tick gave a different error. does that help?
root#678cf3cd1587:/home# mysqlimport --columns='head -n 1 discounts.csv' --ignore-lines=1 temp discounts.csv -u root -p
Enter password:
mysqlimport: Error: 1064, 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 '-n 1 discounts.csv)' at line 1, when using table: discounts
root#678cf3cd1587:/home# mysqlimport --columns="head -n 1 discounts.csv" --ignore-lines=1 temp discounts.csv -u root -p
Enter password:
mysqlimport: Error: 1064, 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 '-n 1 discounts.csv)' at line 1, when using table: discounts
root#678cf3cd1587:/home# mysqlimport --columns=`head -n 1 discounts.csv` --ignore-lines=1 temp discounts.csv -u root -p
Enter password:
mysqlimport: Error: 1049 Unknown database 'date,amount'
EDIT2
If i do it without a table created I get Error: 1146, Table 'temp.discounts' doesn't exist, when using table: discounts
root#678cf3cd1587:/var/lib/mysql-files# mysqlimport temp /var/lib/mysql-files/discounts.csv -u root -p --columns=`head -n 1 /var/lib/mysql-files/discounts.csv` --ignore-lines=1
Enter password:
mysqlimport: Error: 1146, Table 'temp.discounts' doesn't exist, when using table: discounts
If i then create the table and then try again
mysql> CREATE TABLE discounts (
-> id INT NOT NULL AUTO_INCREMENT,
-> title VARCHAR(255) NOT NULL,
-> expired_date DATE NOT NULL,
-> amount DECIMAL(10,2) NULL,
-> PRIMARY KEY (id)
-> );
Query OK, 0 rows affected (0.03 sec)
mysql>
mysql>
mysql>
mysql> show tables;
+----------------+
| Tables_in_temp |
+----------------+
| discounts |
+----------------+
1 row in set (0.00 sec)
mysql> select * from discounts;
Empty set (0.00 sec)
I get the following error Error: 1265, Data truncated for column 'id' at row 1, when using table: discounts
root#678cf3cd1587:/var/lib/mysql-files# mysqlimport temp /var/lib/mysql-files/discounts.csv -u root -p --columns=`head -n 1 /var/lib/mysql-files/discounts.csv` --ignore-lines=1
Enter password:
mysqlimport: Error: 1265, Data truncated for column 'id' at row 1, when using table: discounts
root#678cf3cd1587:/var/lib/mysql-files#
I am using /var/lib/mysql-files/discounts.csv explicitly because, if i understand correctly, this is the only directory i can import files from with secure_file_priv
mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.01 sec)
mysql>
EDIT3
I got this to work
mysqlimport --columns="`head -n 1 /var/lib/mysql-files/discounts.csv`" --ignore-lines=1 temp /var/lib/mysql-files/discounts.csv -u root -p --fields-terminated-by=',' --fields-optionally-enclosed-by='"'
root#678cf3cd1587:/home# mysqlimport --columns="`head -n 1 /var/lib/mysql-files/discounts.csv`" --ignore-lines=1 temp /var/lib/mysql-files/discounts.csv -u root -p --fields-terminated-by=',' --fields-optionally-enclosed-by='"'
Enter password:
temp.discounts: Records: 7 Deleted: 0 Skipped: 0 Warnings: 0
root#678cf3cd1587:/home#
root#678cf3cd1587:/home# cat /var/lib/mysql-files/discounts.csv
id,title,expired_date,amount
1,"1Spring Break ",20140401,20
2,"2Spring Break ",20140401,20
3,"3Spring Break ",20140401,20
4,"3Spring Break ",20140401,20
5,"3Spring Break ",20140401,20
6,"3Spring Break ",20140401,20
7,"3Spring Break ",20140401,20
But I had to create the table first in my sql, as above.
CREATE TABLE discounts (
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
expired_date DATE NOT NULL,
amount DECIMAL(10,2) NULL,
PRIMARY KEY (id)
);
I also had to use this file /var/lib/mysql-files/discounts.csv as secure_file_priv is set so that I can only load files from this directory, as I understand it.
mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.01 sec)
It looks like the space in "expired date" may be tripping you up. On the command line you'll need to quote the --columns argument, while keeping the backticks.
mysqlimport --columns="`head -n 1 discounts.csv`" \
--ignore-lines=1 temp discounts.csv -u root -p
Is the table column name actually "expired date" with the space? If so you'll need to account for that in your csv file with backticks.
id,title,`expired date`,amount
Also, ensure you specify the format of the file if it differs from the default of
FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\' LINES
TERMINATED BY '\n' STARTING BY ''
In your case,
--fields-terminated-by=',' --fields-optionally-enclosed-by='"'

Mysqlimport does not work on ubuntu 14.04

i have installed Server version: 5.6.25 MySQL Community Server (GPL) on my laptop with OS ubuntu 14.04 lts. Recently i tried to run mysqlimport client program and got errors that i was unable to figure out.
on terminal i type this command and got this error:
mysql> mysqlimport --local test_database employee.txt;
ERROR 1064 (42000): 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 'mysqlimport --local test_database employee.txt' at line 1
Initially, i thought that may be the problem is in the employee.txt file directory which i stored under var/lib/mysql directory.But when i tried this most basic mysqlimport command i again got error!:
mysql> mysqlimport --help;
ERROR 1064 (42000): 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 'mysqlimport --help' at line 1
Thus, i think my current mysql 5.6.25 does not have mysqlimport support.I tried to follow this RPM Package Client Utilities..However that was for linux not ubuntu & all the given Package versions are 5.6.26 not 5.6.25.BTW all of my other configurations such as phpmyadmin & database query works fine.
Therefore, in that situation how should i resolve the problem ?
let me know for further information.
Thanks
Thanks alvits , finally i tried this modified commands from outside the mysql in another terminal:
mysqlimport --local -u root -p test_database home/himadree/mysqlTestingFiles/employee.txt;
it works,BUT the data inside the employee.txt were not correctly restored into the table. my actucal employee.txt contains this tab-dalimated data below:
100 John Doe DBA
200 John Smith Sysadmin
300 Raj Patel Developer
But after mysqlimport command i got this output:
select * from employee;
+-------+-----------------+------+
| empno | ename | job |
+-------+-----------------+------+
| 100 | John Doe | NULL |
| 200 | NULL | NULL |
| 300 | NULL | NULL |
+-------+-----------------+------+
3 rows in set (0.00 sec)
why i m getting some incorrect data on the table?
Yes Finally i realized that there were some extra tabs in the text file & last commands were fine.
Now here is my final table:
mysql> select * from employee;
+-------+------------+-----------+
| empno | ename | job |
+-------+------------+-----------+
| 100 | John Doe | DBA |
| 200 | John Smith | Sysadmin |
| 300 | Raj Patel | Developer |
+-------+------------+-----------+
So, anyone trying to learn the mysqlimport program then be careful:
whether the input text file properly delimited or not.
use mysqlimport program outside from mysql program itself with opening another terminal/shell on your OS etc.
Thanks a lot.
In Ubuntu, shell, I ditched mysqlimport and instead use:
MYSQL -h blah < file.sql

MySQL: check what version : 32 bit or 64 bit?

Can I tell what version (32 bit or 64 bit) of MySQL I am running by using Terminal?
$ mysql --version
mysql Ver 14.14 Distrib 5.1.45, for apple-darwin10.2.0 (i386) using readline 6.2
$ echo '\s' | mysql
--------------
mysql Ver 14.14 Distrib 5.1.45, for apple-darwin10.2.0 (i386) using readline 6.2
Connection id: 105730
[...]
Server version: 5.1.41 MySQL Community Server (GPL)
[...]
Uptime: 11 days 4 hours 2 min 6 sec
Threads: 2 Questions: 1141270 Slow queries: 0 Opens: 6137 Flush tables: 1 Open tables: 56 Queries per second avg: 1.182
--------------
run this command in command line:
mysql> show variables like 'version_compile_machine';
then you get something like this:
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| version_compile_machine | i386 |
+-------------------------+-------+
1 row in set (0.00 sec)
and then please check this: http://www.redhat.com/archives/rhl-list/2006-October/msg03684.html
you'll see that i386/i686 are 32 bit, and x86_64 is 64 bit.
Hope this helps.
You can use version():
SELECT version();
See more information here :)
Running the command-line MySQL client:
mysql> select version();
OR
mysql> \s
which is an alias for:
mysql> status
You could try the command: (no login needed)
mysql -V
To know your Mysql bit architecture please follow this step.
Open Mysql console from phpmyadmin
Now after entering password type this command
show global variables like 'version_compile_machine';
if version_compile_machine = x86_64 then it is 64 bit
else 32 bit.
I was searching for this also (core dump issues connecting to mysql) and it seemed none of the above answers properly answered the question: e.g. mysql version info doesn't include the build type 32or 64 bit.
found this capttofu: Do I have a 32-bit or 64-bit MySQL? captoflu which uses a simple "file" command to tell what build youre running, in my case.
BensAir:~ Ben$ /usr/local/mysql/bin/mysqld --verbose --help
file /usr/local/mysql/bin/mysqld
/usr/local/mysql/bin/mysqld: Mach-O 64-bit executable x86_64
Get mysql version In Windows with --version parameter:
C:\>C:\xampp\mysql\bin\mysql.exe --V
C:\xampp\mysql\bin\mysql.exe Ver 14.14 Distrib 5.6.11, for Win32 (x86)
Get mysql version In Windows with custom query:
C:\>C:\xampp\mysql\bin\mysql.exe
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.11 |
+-----------+
1 row in set (0.00 sec)
mysql>
Get mysql version in Windows with server variable:
mysql> select ##Version;
+-----------+
| ##Version |
+-----------+
| 5.6.11 |
+-----------+
1 row in set (0.00 sec)
mysql>
Get mysql version in Windows with \s flag.
mysql> \s
--------------
C:\xampp\mysql\bin\mysql.exe Ver 14.14 Distrib 5.6.11, for Win32 (x86)
Connection id: 25
Current database:
Current user: ODBC#localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.11 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: cp850
Conn. characterset: cp850
TCP port: 3306
Uptime: 2 hours 48 min 52 sec
Threads: 1 Questions: 169 Slow queries: 0 Opens: 75 Flush tables: 1 Open
tables: 68 Queries per second avg: 0.016
--------------
Use ##version server variable.
select ##version;
This is what I get on my server:
mysql> select ##version;
+-----------------+
| ##version |
+-----------------+
| 5.0.67-0ubuntu6 |
+-----------------+
1 row in set (0.00 sec)
Hope it helps.
Here's a list of all server variables.
No login is needed (OS X 10.11).
$ /usr/local/mysql/bin/mysqld --version