当前位置:网站首页>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
边栏推荐
- 什么是ESP/MSR 分区,如何建立ESP/MSR 分区
- 非分区表转换成分区表以及注意事项
- 通讯协议设计与实现
- [疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
- [Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
- Ctfhub -web SSRF summary (excluding fastcgi and redI) super detailed
- [爬虫]使用selenium时,躲避脚本检测
- 图像像素读写操作
- leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
- Object. Simple implementation of assign()
猜你喜欢
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
JS to convert array to tree data
Multi row and multi column flex layout
基于NeRF的三维内容生成
数据库安全的重要性
Static comprehensive experiment
BGP actual network configuration
Minimalist movie website
Static vxlan configuration
ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型
随机推荐
详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
idm服务器响应显示您没有权限下载解决教程
【从 0 开始学微服务】【00】课程概述
Using stack to convert binary to decimal
[learn microservice from 0] [01] what is microservice
Guangzhou held work safety conference
聊聊Redis缓存4种集群方案、及优缺点对比
[binary tree] delete points to form a forest
利用栈来实现二进制转化为十进制
【二叉树】删点成林
广州市召开安全生产工作会议
The IDM server response shows that you do not have permission to download the solution tutorial
Day21 multithreading
Cookie
Ctfhub -web SSRF summary (excluding fastcgi and redI) super detailed
Leetcode skimming: binary tree 20 (search in binary search tree)
HZOJ #240. 图形打印四
Configure an encrypted web server
Vxlan 静态集中网关
Static routing assignment of network reachable and telent connections