Note that this is in Linuxbash and cannot be used in Windows .. However, you can try to write a bat batch file to achieve the same effect! To run a mysql file, such
Note that in Linux bash, this is certainly not supported in Windows .. However, you can try to write a bat batch file to achieve the same effect! To run a mysql file, such
Note that in Linux bash, this is certainly not supported in Windows .. However, you can try to write a bat batch file to achieve the same effect!
To run the mysql file,If you have logged on to mysql, you can directly run: source filename. SQL In the mysql command line., Very simple!
But isn't that too troublesome?
Okay .. Run it directly on the command line .. You can enter:Mysql-u USERNAME-pPASSWORD DATABASENAME <filename. SQL
Here, USERNAME is the USERNAME you want to log on to, PASSWORD is the PASSWORD, and DATABASENAME is the name of the database you want to use, which is short of oil !! La !!!~
The input is too long. Right !!! Trouble!
Change it. Write an alias and write it to The. bashrc file !!! But in order not to conflict with the original, the alias is now taken as SQL ..
Vim ~ /. Bashrc
Add this line at the end of SQL = "\ mysql-u username-pPassword datebasename <" # note that there is a "\" behind mysql
# Do not reference an alias that already exists. You need to escape it. Of course you have not defined any other alias. It doesn't matter!
This is near perfect, isn't it?
But this is better for beginners!
Alias SQL = "\ mysql-u USERNAME-pPASSWORD -- auto-rehash -- line-numbers -- show-warnings DATABASENAME <"
Then run the script:Source ~ /. Bashrc
OK. Now you can run the script file directly. For example, if you have written a test. SQL file, you can run it like this:
SQL test. SQL
This is more convenient .. At least I think so .. In addition, the input is a line in the mysql command line. I prefer to write a file !!!