I copied an sql text file into /var/lib/mysql-files directory but the command:
>mysql -u root -p < /var/lib/mysql-files/test.sql
but I get the error:
bash: /var/lib/mysql-files/test.sql: Permission denied
The file has permissions set to 0744.
You can use MySQL dump for this.
For creating a backup use:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
For restoring a version use:
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
Related
I am trying to import a database with a .sql file but when I'm trying it nothing happens:
user:~$ sudo mysql -u root -p database_name < Documents/Project/Projects-db/file.sql
Enter password:
user:~$
I was trying to migrate my WordPress blog from the server and somehow I corrupted my sql database.
I have typed these commands into my Centos VPS:
mysqldump -u root -QqeR --add-drop-table --databases blogsql -> blog.sql
mysql -u root blogsql -> blog.sql
mysql -u root blogsql > blog.sql
mysql -u root -p blogsql > blog.sql
mysql -u root -p blogsql > blog.sql
mysql -u root -p blogsql > blog.sql
mysql -u root -p blogsql > blog.sql
mysql -u root blogsql > blog.sql
Your using the wrong operator.
> redirects output which is what you want for the dump
< is what you want to restore
so
mysql -u root -p blogsql < blog.sql should import it
also typo in the first line
mysqldump -u root -QqeR --add-drop-table --databases blogsql -> blog.sql
should be
mysqldump -u root -QqeR --add-drop-table --databases blogsql > blog.sql
Thank you guys for the help, the database was not corrupted, just iptables was blocking my 80port so I thought I have overwitten the database, but it had no issues.
anyways thank you for the help guys!
Using mysqldump on windows(2003-server - MariaDB) produces following error:
mysqldump: Got error: 1045: "Access denied for user 'ODBC'#'localhost' (using password: YES)" when trying to connect
Commands I used:
mysqldump --user=root --password=password -h127.0.0.1 --port=3306 database > backup.sql
mysqldump -uroot -ppassword database > backup.sql
mysqldump -uroot -p(enter password on promt) database > backup.sql
mysqldump -u root -p password database > backup.sql
mysqldump -u root -ppassword database > backup.sql
Etc, anything I used, same error popped up.
Looks like some default-hardcoded user/password is used.
I can connect to mysql -uroot -p just fine.
Internets have seen this error before, but I have not seen proper solution to this or I am oblivios to something.
Any insight would be amazing.
Thanks.
Double check your - char in your commands. Sometimes copy&paste produces a different hyphen char.
Your command below should work:
mysqldump -u root -ppassword database > backup.sql
I have a Debian VPS with mysql installed and i want to export a database.
After have successful login in to mysql.
I run the follow command:
mysqldump -u user -p mydatabase > db.sql
but I got the following error:
->
It doesn't export the database and I canĀ“t type anything.
you don't need to login to mysql. Just type:
mysqldump -u user -p mydatabase > db.sql
on the command line, meaning the shell. It will ask you for a password and then writes the dump to db.sql
mysqldump -u root -p Databasename > backup.sql
How to set in this command password? I need run this command in Python script.
At this time, asking me for a password.
mysqldump -u root -pPassword Databasename > backup.sql
Read this for some basic security info.
Assuming you're on Unix...
env MYSQL_PWD=<password> mysqldump -u root -p Databasename > backup.sql
According to the mysql docs.