Setting up timezones in mysql - 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'

Related

Backwards compatible mysql dump

I am trying to port a database from mysql 5.7 to mysql 5.5.
At first, I used the following command
mysqldump -u root -p --all-databases > alldbs.sql
When I try to import the DB in mysql 5.5 I keep getting errors like
ERROR 1064 (42000) at line 572: 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 'STATS_PERSISTENT=0' at line 9
where it complains about STATS_PERSISTENT=0 statement.
Then I tried
mysqldump -u root -p --compatible=mysql40 --all-databases > alldbs.sql
but this just gives me
ERROR 1064 (42000) at line 26: 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 'TYPE=InnoDB' at line 22
where it complains about TYPE=InnoDB statement, which should be ENGINGE=InnoDB. Even with the --compatible option it still keeps the STATS_PERSISTENT statement.
Is there a way to port a mysql 5.7 database to mysql 5.5?
UPDATE
To be clear on my question, I am looking for relialble, i.e. no-hack way, to port the database. I already tried to replace TYPE with ENGINE, remove STATS_PERSISTENT etc. Something else always came up. I am not willing to jump through those hoops everytime I port the database. I am looking for a reliable way via mysqldump or a similiar tool to do the job.
If this is not possible then I will have to switch to an alternative DB.

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;

Unable to create mysql database dump

I am unable to create mysql database dump. I have tried all the commands in the below question
https://stackoverflow.com/questions/24858436/unable-to-create-mysql-dump-in-mysql-server-5-6-19
But every time I get similar error which asks me to check manual
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
dump -u root -pmysqlmysql hospital_management -r "c:\hosp.sql"' at line 1
I am trying these commands in Mysql command line and NOT on Windows command prompt. Also I am trying these commands before entering any database in mysql.
mysql> mysqldump -u root -pmysqlmysql hospital_management > hosp.sql
This was the first command I tried, which did not work
mysqldump is an executable, you should not run it in the MySQL command line.
Try the command
mysqldump -uroot -pmysqlmysql hospital_management > "C:\hosp.sql"
By reading the documentation, I assume that when using -r, the file must already exist.

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

mysql console > mysqlbinlog You have an error in your SQL syntax

I have WAMP installed that has been binary logging all changes in my database. I found the logs, the mysql console also shows them when I perform a SHOW BINARY LOGS. But when I try to read them by executing:
mysqlbinlog mysql-bin.000197
it gives me that error:
ERROR 1016(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 'mysqlbinlog mysql-bin.000197' at line 1
MySQL version is 5.5.20
have you used shell command ?
shell> mysqlbinlog mysql-bin.000197