This question already has answers here:
mysqldump backup and restore to remote server
(6 answers)
Closed 4 years ago.
I have a SQL file in my local computer size of 9.5Gb. And I want the dump that SQL into the live server through the command line. I want to know the command line to dup the SQL from local to live server
mysql -u root -p db_name < /path of sql file
mysql -u username -p db_name -h hostname < /path/file.sql
Related
This question already has answers here:
How to feed mysql queries from bash
(7 answers)
Closed 5 years ago.
So I am attempting to make my first Linux script and its just to setup a MySQL user and I'm trying to do that all with a script, but I can not seem to find how I can send the MySQL command from the script. This is what I have right now.
#!/bin/bash
read -p "Please enter your desired MySQL username: " USER
echo $USER
read -p "Please enter your desired MySQL password: " PASS
echo $PASS
mysql CREATE USER $USER#'localhost' IDENTIFIED BY $PASS;
any help would be appreciated
Thanks
-Jamie
You cannot mixup mysql queries in bash script.So, you have to save the mysql queries to a mysql file i.e .sql file and then run the mysql command
To append the create user line to a .sql file use
echo 'mysql CREATE USER $USER#'localhost' IDENTIFIED BY $PASS' >> filename.sql
Now the .sql file will contain the sql queries and you can run
$ mysql -h "server-name" -u "root" "-pXXXXXXXX" "database-name" < "filename.sql"
This question already has answers here:
Batch file to connect mysql and run commands
(3 answers)
Closed 6 years ago.
I want to create a batch-file which executes a local saved (MY)SQL Text file (sql procedure) The tables created by the execution of the sql-file will use data from a server I have access to (hostname: server1; Port: 3306, (my) username: User2 Password:I´m using no password so the password is empty, Connection Name: ConnectiontoSQLServer, Name of Schema: ABC )
->How will the command in the batch-file look like?
Thanks for your support!
I tried this now, but it´s not working:
mysql --host=server1 --port=3306 --user=User2 --password= --database=ABC < C:\Users\krohn\Documents\Arbeit\SQL Queries\Tabellen CRM-Work\Tabellenaktualisierung.sql
-> What´s wrong?
You can "execute" sql files on command line:
mysql -h server1 -u User2 < C:\Users\X\...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Hi I want to insert sql database dump file in remote mysql server machine. i am using currently putty tool for doing this task. i have used lot of command but i am not able to do this. and i have also created database on that server but now i want insert database sql dump from server directory into mysql server.
I have also uploaded sql dump into home directory RHEL OS remote server machine.
i have used some command like -
mysql> use database_name;
mysql> mysql -u username -p database_name < /home/dump.sql;
mysql> mysql -u username -h host_ip -p database < /home/dump.sql;
mysql> mysql -u username -h host_ip -p database < /home/dump.sql;
mysql> mysql -u username -h host_ip -p dbpass -d database < /home/dump.sql;
mysql> mysql -u username -h host_ip database < /home/dump.sql;
mysql> plink mysql -u username -h host_ip -p database < /home/dump.sql;
and other command but i could not import sql dump into db server.
Please help me.
Thanks.
i think you are missing the password after -p syntax is
mysql -u username -p password db_name < /home/dump.sql
other possibility is that you are not providing proper directory or complete path of dump file
This question already has answers here:
how can I export mysql database using ssh?
(3 answers)
Closed 9 years ago.
I want to download mysql database from server using command prompt in windows.
I tried to use ssh to connect to the server.
But, it is not working. Is there any command to this?
Exporting MySQL Data
This example shows you how to export a database. It is a good idea to export your data often as a backup.
Using SSH, execute the following command:
mysqldump -p -u username database_name > dbname.sql
You will be prompted for a password, type in the password for the username and press Enter. Replace username, password and database_name with your MySQL username, password and database name.
The file dbname.sql now holds a backup of your database and is ready for download to your computer.
To export a single table from your database you would use the following command:
mysqldump -p --user=username database_name tableName > tableName.sql
Again you would need to replace the username, database and tableName with the correct information.
Once done the table specified would then be saved to your account as tableName.sql
Have a look Backup or Schema/Data Comparison tools in dbForge Studio for MySQL. Command line and conencting through secure SSH connections are supported.
This question already has answers here:
How do I rename a MySQL database (change schema name)?
(46 answers)
Closed 9 days ago.
I am developing a web project using Java and MySQL. I am using Mysql Workbench. I started the work but now I need to change the database name. I tried
ALTER DATABASE Test MODIFY NAME = NewTest
and
USE master
GO
ALTER DATABASE Test
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE Test MODIFY NAME = NewTest
GO
ALTER DATABASE NewTest
SET MULTI_USER
GO
But these two are showing syntax error. What is the proper way to change database name in MySQL?
Renaming a schema is not possible in MySQL. For the correct ALTER SCHEMA syntax see the online manual.
I ran this code from a Microsoft Windows command prompt:
cd %ProgramFiles%\MySQL\MySQL Server 5.6\bin
mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql