I have created a project which is using a database , prepared in mysql. To submit this project i need to create a .sql file.
I am not using workbench. Can any one guide me on how to make the .sql file using terminal. I have created all of my database using terminal. I am working on ubuntu.
nysqldump -u db_username -p database_name > database_name.sql
Then enter and it will ask the password, enter the password and and hit enter, thats it it will create the .sql file for you
Here is an example in my ubuntu machine
abhik#ubuntu-desktop:~$ mysqldump -u root -p test >test.sql
Enter password:
abhik#ubuntu-desktop:~$
I am currently on Desktop folder so the file is saved under Desktop
If you want To export:
mysqldump -u mysql_user -p DATABASE_NAME > backup.sql
To import:
mysql -u mysql_user -p DATABASE < backup.sql
Related
I wanted to create a database, so I started doing it by a video tutorial. When I created a file .bash_profile I opened it in the editor and added a command
export PATH=${PATH}:/usr/local/mysql/bin/
After that I wanted to connect to the mysql server by command mysql -u root -p, but it didn't work and showed command not found.
What should I do?
I have Mysql installed on my local PC and want to use mysqldump on my local pc to dump a remote database. So I open CMD and run the following command:
mysqldump -P 3306 -h 12.43.33.43 -u admin -p myDatabase > mydb.sql
So in the next line it should ask for my password? but instead i get the response 'Access is denied'. Am i missing something here?
ps.
If I try the following:
mysqldump -P 3306 -h 12.43.33.43 -u admin -p myDatabase
it will successfully ask for my password and start printing the dump in cmd, but this is no good as i need the response saved in a file.
I only wanted to know if you could connect.
The command is
mysqldump -P 3306 -h 12.43.33.43 -u admin -p --databases myDatabase --result-file=mydb.sql
As the connection is not secure, you send your credentials like a postcard, so that every one can read it.
Besides that having your server exposed to the internet, is very dangerous and can come to a disaster, so reconsider your security strategy and allow only access via ssh.
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 am trying to get database backup from remote system, please anyone help me to get backup from remote system. Here is the query which I executed, but its giving error.
mysqldump --host <host or IP address> -P <port Number> -u <username> -p<password> databaseName > c.sql;
remove ; from your syntax and execute below command-
mysqldump -h<IP_address> -u <username> -p<password> databaseName > backup.sql
If you want to take backup in your working directory else give a path. I have removed port option here as assuming that it will be running on default port 3306 else add in command.
Make sure your user should have permission on db server.
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