The Mysql command line imports sql data

  • 2020-05-09 19:29:17
  • OfStack

My personal practice is: phpmyadmin exports utf-8 to abc.sql in insert mode
ftp abc.sql to the server
ssh to the server
mysql-u abc-p use KKK(database name, if not create database KKK) set names 'utf8' source abc.sql
Note: I see set character set utf8; That's not good.
1. First open mysql in the command line console
Perhaps it was ordered as follows:
mysql -u root -p database_name
You may then be prompted for the corresponding password
2. The following command may be useful when you want to change a database
mysql > use database_name
Then use the following command
mysql > source d:\datafilename.sql
Of course you need to figure out where the file is and use it correctly
Enter bin, a subdirectory of the directory where the mysql installation is located. Enter the command to execute the import of sql.
For example: your mysql is installed at d:\mysql
The steps are as follows:
Start - > Run - > Input CMD
D:
cd mysql\bin
mysql -u root -p123456 test < d:\a.sql
Where root is your mysql administrator username and 123456 is your password, test is your database name, d:\ a.sql is the location of the data files that have been backed up.
If it's Windows, go from the command prompt to the Bin folder in the MYSQL file directory and execute the command
mysql -u root -p databasename < db.sql
root is your MYSQL username,databasename is the name of your database, and db.sql is your file.
If it's LINUX, enter it directly

mysql databasename < db.sql

Related articles: