import large MySQL Database - PHPMyAdmin error - mysql

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;

Related

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

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

SQL Restore backup file error

mysql -u root -paaum corpdb < /home/aaum/Videos/sp_getNOnAirDetails1.sql
ERROR 1064 (42000) at line 1: 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 '' at line 4
i think so there is some problem with my sql file
Try the commands as shown below :
Login into your mysql console and run :
mysql> use corpdb;
mysql> source /home/aaum/Videos/sp_getNOnAirDetails1.sql;
If your dump file is executed perfectly then the issue is not with the file.
It's about how you are trying to import the file.
The command which you have provided is absolutely fine. But I see that probably you might be executing the command from MySQL console.
mysql> mysql -u root -paaum corpdb < /home/aaum/Videos/sp_getNOnAirDetails1.sql
Not a right way to import, try to import the file from terminal.
If you still see any errors then please post them here.
i finally bugged the problem. i forget to assign delimeter .

Unable to get mySQL Dump

I m trying to get a mysql dump of my bugtracker tool. MySQl is installed with the WAMP server and i m trying to get the dump from the mySQL console with the following command:
mysqldump -uroot -p[password] dbname>/DBBackup/dbname_18052017.sql;
but i m getting an error as there is a syntax error,
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 'mysqldump -uroot -p[password]
dbname>/DBBackup/dbname_18052017.sql;' at line 1 can some one help me
figure out this
mysqldump is a utility program. It's not a SQL statement.
Execute mysqldump from the shell prompt just like you execute the mysql command line interface program.
FOLLOWUP
By WAMP, we take that to mean you are running on Windows (not Linux). For Windows...
Start -> Run -> "cmd.exe" enter
Change directory to the location of the MySQL binaries
> cd C:\Program Files\MySQL Server 5.6\bin
This is going to be the directory that contains "mysqldump.exe". The actual name of the directory is going to depend on where MySQL was installed as part of WAMP.
Then
> mysqldump.exe -u user -pmypassword --quick dbname >C:\somedir\backup_20170518_dbname.sql
(Windows will look for an executable in the "current directory". Otherwise, it needs to be in a directory included %PATH% environment variable. Or, you can fully qualify the name of the executable.

Setting up timezones in mysql

I'm a MySQL/WAMP newbie attempting to set up timezones so that I could follow along with a course on the topic, but then I started having troubles when the instructions I was being given didn't correspond to the info on the MySQL page from which I was to download the setup file, http://dev.mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html.
Can anyone tell me why, when I attempt to run this command from the mysql command prompt:
mysql -u root mysql < C:/timezone_posix.sql;
I get this error:
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 'mysql
BTW, I've tried that with both forward and backward slashes, with and without quotes, etc., from my WAMP 5.6.17, MySQL command prompt, and the file in question is the posix (not isam) version that corresponds to the MySQL version on a windows machine.
You should be running that from the regular command prompt, not inside the mysql program, since it runs the mysql program. So it should be at the C:\ prompt.
Or you could use the mysql source command to read from a file:
mysql> use mysql
mysql> source 'C:/timezone_posix.sql'

How to import MYSQL Dump into Amazon RDS

I just logged into my EC2 via Putty on Windows and I got into my RDS instance and into one database I had created. Then I try to import a SQL dump from my machine with the following code which results into an error.
mysql> source C:\Users\guru\Downloads\latest.sql;
ERROR:
Unknown command '\U'.
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 'source C:\Users' at line 1
ERROR:
Unknown command '\D'.
ERROR:
Unknown command '\l'.
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 'uru\Downloads\latest.sql' at line 1
The file exists in my Windows machine. Please help me resolve the error.
As datasage mentioned, you would probably be better off working from your EC2 -> RDS instances. If you really want to work from your local machine, though:
Install MySQL for Windows: http://dev.mysql.com/downloads/mysql/
Add the parent directory of mysql.exe (the mysql command line tool) to your path environment variable.
Try the following in the command prompt. You could use powershell also, but you would need to wrap this statement in cmd /c "mysql etc..." because powershell handles redirection a little differently.
mysql -u myUser --password=myPass -h rdsEndpoint myDB < C:\Users\guru\Downloads\latest.sql
This procedure would also be useful to know if you have need for a Windows EC2 instance.
As an aside: extracting data from RDS to your local machine can get pricey, especially as your database grows. If you're just doing this as a backup solution, then you may want to look into Snapshots or automated backups. If you are doing this to replicate your RDS environment you could also transfer your data directly from RDS to your EC2 instances, which is free if both instances are in the same availability zone.
I found a very simple and user friendly solution: Downloaded SQLyog https://www.webyog.com and fed in my ssh details for my ec2 and my MYSQL log in details. I ended up accessing a my database using this GUI tool that has all the options for importing and exporting data as easy as on localhost/phpmyadmin