Accidentally dropped table from mysql server [duplicate] - mysql

This question already has answers here:
How do I restore a dump file from mysqldump?
(19 answers)
Closed 5 years ago.
I'm new to MySQL, and I accidentally dropped a table with approx 3gb worth of data. Good news, I think I have a backup file .dump. Now is there an easy way to import this file to my MySQL?

mysql -u username -p databse_name < backup.sql

Related

Run sql in Dockerfile starting from exisiting MySQL db image [duplicate]

This question already has answers here:
How to create populated MySQL Docker Image on build time
(6 answers)
How can I initialize a MySQL database with schema in a Docker container?
(11 answers)
Closed last month.
I am trying to build a new mysql image from an existing one, and then insert some records into the database as part of the build process to create the new image (i.e. new mysql image = old mysql image + extra table records).
I am not able to add an sql file that contains my insert queries to /docker-entrypoint-initdb.d, cause that is not executing the scripts inside that directory (because the starting image already has a /var/lib/mysql dir available?).
I have tried to do something like the following instead:
FROM my.registry/starting-mysql-img:latest
ADD insert-queries.sql /tmp
RUN mysql -u root mydb < /tmp/insert-queries.sql
But I get a
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error.
What am I doing wrong / is there an alternative way to achieve my I am looking for?

mysqldump comand showing blank [duplicate]

This question already has answers here:
mysqldump command not working?
(2 answers)
Closed 2 years ago.
I want to export large database using command line mysqldump but when i use the command mysqldump it shows blank and nothing happen.
mysqldump must be run from the regular shell, not inside the mysql program.
Type ; followed by Return to end the command you've started typing. You'll get an error because mysqldump is not a valid SQL query.
Type quite to get out of the mysql program and back to the normal command prompt.
Then type your mysqldump command line. You'll need to provide some arguments, such as the database and table names to dump.

How to import a 10GB file to MySQL? [duplicate]

This question already has answers here:
How can I import a large (14 GB) MySQL dump file into a new MySQL database?
(11 answers)
Closed 3 years ago.
"I am trying to import a backup file to MySQL. The file is 10GB but the problem I get an error when the backup reach the limit of max_allowed_packet which is: 1GB. Any idea how can I increase this number to 10GB ?"
I've tried to use this command:
mysql -u username -p database_name < file.sql
But i get the same error
I expect that i have to change the max_allowed_packet and net_buffer_length but how could i do that ?
Thank you!
Set the max_allowed_packet and net_buffer_length through mysql command line client
set global net_buffer_length=10000000;
set global max_allowed_packet=10000000000;

Bash: mysqlimport command to write to database without prompt [duplicate]

This question already has answers here:
How do I import an SQL file using the command line in MySQL?
(54 answers)
Closed 4 years ago.
I'm trying to restore the empty DB for mydb table but the syntax of mysqlimport doesn't seem to be straight forward. I had earlier created the file emptyDbs when doing a mysqldump.
mysqlimport mydb/var/tmp/emptyDbs
mysql statsdb < /var/tmp/emptyDbs

How may I copy all my existing application Data from sqlite3 to MySQL in Rails? [duplicate]

This question already has answers here:
Convert a Ruby on Rails app from sqlite to MySQL?
(5 answers)
Closed 5 years ago.
I am working on a project in Rails 4. I was using sqlite3 database previously. But now I want to switch the database from sqlite3 to mysql. But all my previous application data should be copied so when I use mysql database none of my table data may be deleted.
try this
1. cd /path/to/rails_app/db
2. sqlite3 DATA-BASE-NAME .dump > database.sql
3. mysql -u username -p -h localhost DATA-BASE-NAME < database.sql
Hope it will help you.