0

I made mysql queries in "test.sql" file, but doesn't work. This is my sql code.

*test.sql

UPDATE articles SET count = count + FLOOR(RAND()*5) WHERE ((UNIX_TIMESTAMP(created_at) - UNIX_TIMESTAMP())<86400);
UPDATE articles SET count = count + FLOOR(RAND()*5) WHERE ((UNIX_TIMESTAMP(created_at) - UNIX_TIMESTAMP())<172800);

I tried this.

/usr/bin/mysqldump -uadmin -ppasswrod testdb > /home/test.sql

but any response was nothing, and doesn't work.
also, contents of the database have not changed.

[root@test Parse]# /usr/bin/mysqldump -ummdance -psecret mmdance > /home/qquing/public_html/Parse/mmd_view_update.sql
[root@test Parse]#

however, this is worked in mysql.

MariaDB []> UPDATE articles SET count = count + FLOOR(RAND()*5) WHERE ((UNIX_TIMESTAMP(created_at) - UNIX_TIMESTAMP())<86400);
Query OK, 1176 rows affected (0.02 sec)
Rows matched: 1486  Changed: 1176  Warnings: 0

What is problem?
thanks in advance your help.

1 Answer 1

1

You are trying to direct the command into the .sql, which is backwards:

/usr/bin/mysqldump -uadmin -ppasswrod testdb > /home/test.sql

Instead, direct the .sql file into the call to mysql:

/usr/bin/mysql -uadmin -ppasswrod testdb < /home/test.sql

Check the documentation for more information.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks. but I'm sorry, this error occured. => ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Ctrl-C' at line 1
@User8392 Well this looks good...you're hitting MySQL at least. Can you check your script for escape/control characters? It looks like MySQL did not like something inside the script. If you get stuck, then pare down the script, line by line, until it runs. Then add stuff back until you find exactly where it is breaking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.