ERROR 3554 (HY000) at line 318: Access to system table 'mysql.innodb_index_stats' is rejected.
Operation failed with exitcode 1
11:27:20 Import of C:\Users\VELOXSHOP\Downloads\dumpfilename.sql has finished with 1 errors
How do I allow acess to that table?
You'll need to make a new dump/backup of your old database, this time remove those innodb tables from your target. You can do this by using --ignore-table parameter on the command line:
mysqldump -u root -p --all-databases --ignore-table=mysql.innodb_index_stats --ignore-table=mysql.innodb_table_stats > dump.sql
Then you should be able to restore your backup on the new database using the command below:
mysql -u root -p < dump.sql
You can also circumvent this error using the --force option which causes mysql client to continue despite errors.
Try to add -f to your command like so:
mysql -u root -p -f < dump.sql
-f means --force.
This did the trick for me!
It seems to be restricted in Mysql 8. Remove the insert statement from the sql file. You may have to use sed if the file is very large
https://stackoverflow.com/a/26379517/1106420
https://bugs.mysql.com/bug.php?id=92675
That is a MySQL system table and it's unlikely that you should be inserting records into it directly. MySQL should update the table when it calculates new statistics for indexes when thresholds pass.
Inspect line 318 and figure out why it's trying to insert into that table.
Related
We have a cron that does a full dump of the MySQL5 server, and in tests of restore on a empty instance, it restores all bases, including mysql with mysql.user carrying users and permissions together.
In MySQL8 because mysql base is system, the --add-drop-database and --all-databases attributes conflict giving an error in the restore "ERROR 3552 (HY000) at line 19044: Access to system schema 'mysql' is rejected.", as it is not allowed to drop the mysql base.
Has anyone managed to get around this situation and bring users and privileges together in MySQL8 in same dumpfile?
This is the command i run to dump:
mysqldump --add-drop-database --flush-logs --single-transaction --ignore-table=mysql.innodb_index_stats --ignore-table=mysql.innodb_table_stats --quick --all-databases --triggers --routines --events -u root --password='senha' -P 3306 -h 1.1.1.1 | bzip2 > /tmp/backup.sql.bz2
The problematic SQL:
/*!40000 DROP DATABASE IF EXISTS `mysql`*/;
The best way to walk around this, just open the dump SQL file, delete this SQL,
if the file is too big, use sed.
I ran into this same scenario. I dumped a broken instance with all databases and using add-drop-statement to try and save the data, but when I went to restore it I was blocked. You can no longer drop the mysql system database.
My database backup was something like 150gb, and opening it manually was not an option (a shame as i could tell by doing head -n 50 backup.sql that the problematic statement was within the first few lines).
the statement to remove was
/*!40000 DROP DATABASE IF EXISTS `mysql`*/;
and the sed command for me was:
sed -i 's/\/\*!40000 DROP DATABASE IF EXISTS `mysql`\*\/;/ /g' backup.sql
I would paste the statement into an empty text file first, and run the command to confirm that it actually works. This way you don't waste a ton of time on the execution of a very large backup file -- as there's a chance with your version of sed, or OS, that it might resolve the regular expression differently.
I've got a MySQL database I'm using for a live project and I want to create a copy of it on the same server that I can use for development purposes. I have used MySQL dump to create a copy of the live database. I did this as follows:
mysqldump -u root -p mydatabase_live > mydatabase_dump.sql
I then logged into MySQL and created an empty database called mydatabase_test. I then try to copy the dump to the newly created database_test by logging back out of MySQL and doing the following:
mysql -u root -p database_test < mydatabase_dump.sql
This gives me the error message ERROR 1359 (HY000) at line 527: Trigger already exists.
When I log back into MySQL and examine the triggers on the database I've just took a dump of, I cannot see any triggers with duplicate names. I've tried repeating the above process in case there was some kind of error in the initial dump, but the problem repeats.
Can anyone explain why I'm getting this error message and how to solve this?
I'm using MySQL Ver 14.14 Distrib 5.7.25, for Linux
* NOTE ADDING DETAIL TO THE ANSWER ACCEPTED BELOW *
The MySQL dump file can be opened in a text editor. I used vim. The solution was to find the triggers and change the part of the trigger name which identifies it as belonging to the schema from which you took the dump, changing it to the schema you're aiming the dump at. In my case that meant changing mydatabase_live.my_table to mydatabase_test.my_table. Then logging into mysql, Dropping the test table and then recreating it, before logging out and performing the copy command again.
Triggers are stored on Information_Schema.Triggers table. Maybe that's why you cant duplicate them, maybe create a new one with a different name?
look here for more information
https://dev.mysql.com/doc/refman/8.0/en/faqs-triggers.html
Linux
mysqldump -u root -p mydatabase_live > mydatabase_dump.sql
mysqladmin create database_test
cat mydatabase_dump.sql | sed s/`mydatabase_live`/`database_test`/g | mysql -u root -p database_test
Windows
mysqldump -u root -p mydatabase_live > mydatabase_dump.sql
mysqladmin create database_test
type mydatabase_dump.sql | sed s/`mydatabase_live`/`database_test`/g | mysql -u root -p database_test
Notes
If you're in Windows, you'll need a windows version of sed (e.g. GnuWin32 sed)
I used a variation of several answers from a similar question at DBA Stack Exchange.
I'm using MySQL 5.7
mysqldump in 5.7 includes the database name when exporting triggers and views.
I put my password in an env var and passed it on the command line (i know, i'm bad, i get it). I mention it because I don't know what happens when you pipe data to the mysql executable and then it prompts for a password.
I am trying input datadump to mysql.5.7.19.
I command like below :
mysql -uroot -p temp < temp201708.sql
my my.cnf prints error to /var/log/mysqld.log, but I do not see any error log while dumping.
However, when jobs done, I can not find any tables or data in temp schema. I think I saw some articles that different mysql versions could be a problem. Is it right?
Currently, I do not know what point is wrong, since there were no error log. What should I look for to solve this problem?
Thanks.
FYI, I do not know what version of mysql which made that dump file, I just received from the client.
mysqldump -u root -p DatabaseName > /Path-To-put-The-File/fileName.sql
When doing a dump in mysql:
run cmd
locate location of your mysql server like
Enter:
cd C:\Program Files\MySQL\MySQL Server 5.6\bin
mysqldump -uUsernameHere -pYourPasswordHere dbnamehere > "D:\sample.sql" make sure you have a drive D: in your computer or you can change it.
This is working and tested.
You can use it by calling a .bat file to execute the command.
Otherwise if you want to store a data into your Database use mysql only and not mysqldump and change > to <
like this:
mysql -uUsernameHere -pYourPasswordHere dbnamehere < "D:\sample.sql"
Thanks for answers.
I found the cause.
In the dump file, there are some states like USE mysql;, USE temp;.
So even though I indicate which schema to put in in command line,
it just ignore the command line and follow the script.
I found all of my data in mysql schema.
==========================
Conclusion
if you dump with some command like below
$ > mysqldump -u[user] -p[passwd] [scheme] > dump.sql
it is ok with
$ > mysql -u[user] -p[passwd] [target_scheme] < dump.sql
If not, you should check the contents of .sql file.
I'm on a japanese system using xampp. This is the line I use to dump my database.
c:\xampp\mysql\bin>mysqldump.exe -uroot wp_newsja > dump.sql
Then I create a database on another server.
c:\xampp\mysql\bin>mysqladmin -uroot create db
But when I try to execute the sql...
c:\xampp\mysql\bin>mysql -uroot db < dump.sql
... I get the following error.
ERROR at line 145: Unknown command '¥''.
On a japanese computer windows path slashes / are represented with "¥". Which leads me to believe this is an utf8 issue. Maybe there is a way I can mysqldump with some utf8 flag? Thanks for any assistance! The exported sql is here: http://goo.gl/7MPVG - Error at line 145:
edit: Problem solved:
mysql --default-character-set=utf8 db < dump.sql
Sorry if I wasted anyone's time.
mysql --default-character-set=utf8 db < dump.sql
You can add this argument --default-character-set=utf8 in the command:
mysql -u USERNAME -p my_database --default-character-set=utf8 < "C:/My Document Names Have Spaces/my_dump.sql"
I've finally found this solution and it works fine with my new installed WampServer 2.5. I've also tried to add the default character setting in my.ini, but it's useless. Until I've tried the above argument added in my DOS batch file.
My batch file execute the command, like this way:
7zip x -so %1.%2.7z|%mysql% -uxxxx -pyyyyy %2 --default-character-set=utf8
For example, the 7zip filename is 20141231.google.7z, which contains "google.sql", and the database name is google
My backup process on Linux system was a 7zip compressed. In Winodws, I used an automatic batch file to restore the same contents, so that I can share the same database in my biz trip and work offline from the server.
Hope this method is helpful to you.
I want to backup my database using mysql dump. This is the code I run in Command prompt when the location is mysql bin.
mysqldump -u root -pabc Db -r C:\Documents and Settings\All Users\Desktop\ttttt.sql
abc is the password. and I try to backup to a .sql file in desktop. I use mysql 5.5.
But the following error occured. mysqldump: Couldn't find table: "and"
But there is no table called 'and' in database and I didn't create such a table.But the error say about a 'and' table. How can I back up mysql database without this error.
Try instead:
mysqldump -u root -pabc Db -r "C:\Documents and Settings\All Users\Desktop\ttttt.sql"
Your command shell is breaking apart the pathname into multiple arguments. The quotes tell the shell to pass it all as a single argument to the mysqldump program.
I think there is some problem with syntax of command you are running. try something like this :
mysqldump -u root -p dbName > path\nameOfFile.sql
It will automatically ask for your password. You don't need to write it in command.