CSJS software platform development notes-the use of MySQL database

mysql database version 8.0.19

1. Database login

Enter the bin directory of the installation package, open the cmd as the administrator to
start the database,
net start mysql
close the database,
net stop mysql
log in to the machine,
mysql -u root -p
log out
exit

2. File output

select * from tablename
->into outfile 'filepath'
->fields terminated by ',' # 字段分割
->lines terminated by '\r\n'; # 行分割,Windows平台下\r\n回车符加换行符表示下一行

This method requires that the file does not exist, otherwise an error will be reported.
If an error is reported The Mysql server is running with the --secure-file-priv option so it cannot execute this statement
, secure_file_privthere is a problem with the value in the configuration file my.ini. A value of "null" indicates that the file cannot be read or written. A value of the file path indicates that the file can only be read and written in this path. If the value is empty, reading and writing are free The default value is "null". A value of "\" indicates that the path is drive C.

3. File input

mysql command

mysql -u用户名 -p密码 < 文件名或路径

such as:
mysql -uroot -p123 < copy.sql # 将copy数据库导入

source command

Under the specific databaseuse database
source copy.sql # 将copy数据库导入

load data command

load data local infile 'test.txt' into table test
->fields terminated by ','
->lines terminated by '\r\n'

(a, b, c)The order of columns can be adjusted after the table name .

4. Other

(1) In the case of login, the command ends with ";", if there is no response, add "\ g" after the command, which means that the command is sent to the MySQL server.
(2) When creating a table, use backquotes for the table and field names, the one above the tab key.

create table `tset`
->(`col-1` int, `col-2` char(20));

Guess you like

Origin www.cnblogs.com/Heimdall7/p/12728863.html