当前位置:网站首页>MySQL importing SQL files and common commands
MySQL importing SQL files and common commands
2022-07-07 12:49:00 【Full stack programmer webmaster】
stay MySQL Qurey Brower Directly import *.sql Script , You can't execute more than one at a time sql Ordered , stay mysql In the implementation of sql The order of the document :
mysql> source d:/myprogram/database/db.sql;
Attached separately mysql Common commands :
One ) Connect MYSQL:
Format : mysql -h The host address -u user name -p User password
1、 example 1: Connected to the MYSQL
First on DOS window , Then enter mysql Install under directory bin Under the table of contents , for example : D:/mysql/bin, Type the command again mysql -uroot -p, I'll prompt you to enter the password , If just installed MYSQL, The super user root There is no password , Therefore, you can directly enter MYSQL It's in ,MYSQL The prompt for is :mysql>
2、 example 2: Connect to... On the remote host MYSQL ( long-range :IP Address )
Suppose the remote host's IP by :10.0.0.1, The user is called root, The password for 123. Then type the following command :
mysql -h10.0.0.1 -uroot -p123
( notes :u And root You don't need to add space , So are the others )
3、 sign out MYSQL command
exit ( enter )
( Two ) Change Password :
Format :mysqladmin -u user name -p Old password password New password
1、 example 1: to root Add a code 123. First, in the DOS Go down to the directory C:/mysql/bin, Then type the following command :
mysqladmin -uroot -password 123
notes : Because at the beginning root No password , therefore -p The old password can be omitted .
2、 example 2: then root The password of is changed to 456
mysqladmin -uroot -pab12 password 456
( 3、 ... and ) Add new users :( Be careful : Different from the above , The next reason is MYSQL Commands in the environment , So it's followed by a semicolon as the command Terminator )
Format :grant select on database .* to user name @ Log on to the host identified by “ password ”
example 1、 Add a user test1 The password for abc, Let him log on to any host , And query all databases 、 Insert 、 modify 、 Delete permissions . First of all, it is used to root User connection MYSQL, Then type the following command : grant select,insert,update,delete on *.* to [email protected] identified by “abc”;
If you don't want to test2 Password , You can type another command to erase the password . grant select,insert,update,delete on mydb.* to [email protected] identified by “”;
( Four ) Show command
1、 Show database list :
show databases; It started with two databases :mysql and test.mysql Library is very important. It has MYSQL System information , We change the password and add new users , In fact, this library is used for operation .
2、 Display the data table in the library :
use mysql; // Open the library show tables;
3、 Show the structure of the data table :
describe Table name ;
4、 Building database :
create database Library name ;
5、 Build table :
use Library name ; create table Table name ( Field setting list );
6、 Delete database and table :
drop database Library name ; drop table Table name ;
7、 Empty the records in the table :
delete from Table name ;
8、 Show the records in the table :
select * from Table name ;
export sql Script
mysqldump -u user name -p Database name > Storage location
mysqldump -u root -p test > c:/a.sql
Import sql Script
mysql -u user name -p Database name < Storage location
mysqljump -u root -p test < c:/a.sql
Be careful ,test The database must already exist
MySQL Use case of Export Import command
1. Export the entire database
mysqldump -u user name -p Database name > Exported file name
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2. Export a table
mysqldump -u user name -p Database name, table name > Exported file name
mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql
3. Export a database structure
mysqldump -u wcnc -p -d –add-drop-table smgp_apps_wcnc >d:wcnc_db.sql
-d No data –add-drop-table At every create Add a... Before the statement drop table
4. Import database
Commonly used source command
Get into mysql Database console ,
Such as mysql -u root -p
mysql>use database
And then use source command , The following parameters are script files ( As used here .sql)
mysql>source d:wcnc_db.sql Pro feasible measurement
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113468.html Link to the original text :https://javaforall.cn
边栏推荐
- Talk about four cluster schemes of redis cache, and their advantages and disadvantages
- 爱可可AI前沿推介(7.7)
- Simple implementation of call, bind and apply
- 广州市召开安全生产工作会议
- 2022-07-07 Daily: Ian Goodfellow, the inventor of Gan, officially joined deepmind
- ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
- 图像像素读写操作
- 3D content generation based on nerf
- [statistical learning method] learning notes - support vector machine (Part 2)
- 【PyTorch实战】图像描述——让神经网络看图讲故事
猜你喜欢
Leetcode skimming: binary tree 20 (search in binary search tree)
Preorder, inorder and postorder traversal of binary tree
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
Master公式。(用于计算递归的时间复杂度。)
图形对象的创建与赋值
MPLS experiment
The IDM server response shows that you do not have permission to download the solution tutorial
OSPF exercise Report
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
随机推荐
Sorting, dichotomy
3D content generation based on nerf
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
Day-20 file operation, recursive copy, serialization
处理链中断后如何继续/子链出错removed from scheduling
leetcode刷题:二叉树21(验证二叉搜索树)
Image pixel read / write operation
编译 libssl 报错
Leetcode skimming: binary tree 21 (verifying binary search tree)
【统计学习方法】学习笔记——支持向量机(下)
Preorder, inorder and postorder traversal of binary tree
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
@Resource和@Autowired的区别?
Static routing assignment of network reachable and telent connections
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
NPM instal reports agent or network problems
Static comprehensive experiment
MySQL导入SQL文件及常用命令
用mysql查询某字段是否有索引
Object. Simple implementation of assign()