When PowerShell encounters a murder caused by MySQL

Source: Internet
Author: User


------------------"Story"------------------


Cause:
Group Friends asked:
CMD.EXE/C A:\mysql5.6\bin\mysql.exe-uroot < A:\xxx\yyy.sql
Replaced by
POWERSHELL.EXE/C A:\mysql5.6\bin\mysql.exe-uroot < A:\xxx\yyy.sql
Will not.

The study found that PowerShell did not support the "<" number.

Workaround:
Instead of the less-than-sign method, use the source command or CMD.
Start-process-filepath ' A:\mysql5.6\bin\mysql.exe '-argumentlist '-uroot-e "source A:\xxx\yyy.sql" '
Or
Start-process-filepath ' cmd.exe '-argumentlist '/C A:\mysql5.6\bin\mysql.exe-uroot < A:\xxx\yyy.sql '

Instead of the greater than sign method is, with-R. See MySQL Manual for details.
Http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html
Mysqldump.exe-uroot-b-R Library name A:\xxx\yyy.sql
--result-file=file_name,-R file_name


------------------"Expanded discussion"------------------


Q: What is mysqldump?
For:
Export the database and generate the SQL source text.
Query the service port by calling the ip/Port/username/password, get the string, process the string, and then write the text.
The point here is that it is actually producing n rows at a time, writing to the memory cache, (under My.ini, [mysqldump] field, Max_allowed_packet = XXM parameter control) and then chasing
Add a file. Not an additional line. Besides, there is no point in adding a line. and binary append writes no difference.


Q: What are Mysql.exe < xxx.sql?
For:
Load the text and submit it to the server port.
Do I have to use "<" when loading text into the command line? Why Get-content not?

Q: Win,linux command line, the program General number of the wording, what should be?
For:
Command name-parameter value of argument name
Command name--parameter value of argument name
Or
Command name/Parameter Name argument value


PowerShell Missionary original article was allowed to be reproduced in 2016-02-19, but must retain the name and provenance, otherwise be held liable

Q: Has "<" been canceled in PowerShell?
For:
Is


Q: Suppose ">" in PowerShell is canceled, what do I use?
For:
Use
Out-file-inputobject $ content to output-filepath file name
Https://technet.microsoft.com/en-us/library/hh849882.aspx

or with
Set-content-value $ content to output-path file name
Https://technet.microsoft.com/en-us/library/hh849828.aspx


Q: Suppose ">>" in PowerShell is canceled, what do I use?
For:
Use
Add-content-value $ content to output-path file name
Https://technet.microsoft.com/en-us/library/hh849859.aspx

Note: The above PS command supports pipelines, supports single line, supports multiple lines, supports line breaks and does not wrap.


------------------"How does the other database work?" 】------------------

Let's take a look at other database practices first.


Oracle
E:\>exp system/oracle file=c.dmp full=y

Sql server:
sqlcmd
Recovery
Sqlcmd-s./sqlexpress-i C:/createdata.sql

PowerShell
In SQL Server 2012, Microsoft added 4 new backup and restore cmdlets
Backup-sqldatabase
Restore-sqldatabase
Backup-asdatabase
Restore-asdatabase


Conclusion:
These database software, export SQL commands, import SQL commands, are not used to "<", ">", ">>" these symbols.

------------------"thought triggered"------------------


1 Should this not be considered an unreasonable design of the MySQL client program? Bug

2 Should I add--outfile and other parameters to Mysqldump.exe instead of ">"?
For:
Already there is the-R parameter.

3 Should I add--runsqlfile and other parameters to Mysql.exe instead of "<"?
Since the above can not be greater than the number, why this command does not need to be less than the number of parameters?


If you are a monkey, I will take you "<", ">", ">>" brand Banana, you will be very dissatisfied roar?
Do you want to take the monkey's banana???


------------------"Finish"------------------

When PowerShell encounters a murder caused by MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.