search
HomeDatabaseMysql Tutorial MySQL数据库常用基本命令应用分享02

说明:本文来自老男孩linux运维实战培训-MySQL数据库培训课程系列内容1)视频讲解目录1MySQL服务操作.........................................................

说明:本文来自老男孩linux运维实战培训-MySQL数据库培训课程系列内容
1)视频讲解目录
1 MySQL服务操作............................................................................ 3
1.1 启动与关闭MySQL............................................................. 3
 1.1.1 单实例方法............................................................ 3
 1.1.2 多实例方法............................................................ 4
 1.2 登陆MySQL方法................................................................ 4
 1.2.1 单实例方法............................................................ 4
 1.2.2 多实例方法............................................................ 4
1.3 登陆MySQL后................................................................... 4
1.4 善用MySQL的help........................................................... 5
1.5退出MySQL方法................................................................. 7
1.6设置及修改mysql root用户密码...................................... 7
 1.6.1设置密码方法......................................................... 7
 1.6.2修改root密码法一................................................. 8
 1.6.3修改root密码法二................................................. 8
 1.6.4修改root密码法三................................................. 8
1.7如何找回丢失的mysql root用户密码............................... 8
 1.7.1 单实例启动方法..................................................... 8
 1.7.2 多实例启动方法..................................................... 8
 1.7.3 修改密码的方法..................................................... 8
 1.7.4 重启用新密码登陆................................................. 9
2 数据库操作................................................................................. 9
2.1 创建数据库...................................................................... 9
2.2显示数据库...................................................................... 11
2.3 删除数据库..................................................................... 12
2.4 连接数据库..................................................................... 12
2.5 查看当前连接的数据库................................................... 13
2.6 当前数据库包含的表信息................................................ 14
2.7 删除系统多余帐号.......................................................... 14
2.8 创建用户并赋予权限两法................................................ 15
 2.8.1 查看grant帮助................................................... 15
 2.8.1 create和grant配合法........................................ 16
 2.8.2 直接grant法....................................................... 18
 2.8.3 通过实验获得ALL PRIVILEGES包括哪些权限........ 19
 2.8.4 生产环境授权用户的建议..................................... 20
2.9查看mysql的用户........................................................... 23
3 表操作...................................................................................... 23
3.1准备................................................................................ 23
3.2建表................................................................................ 24
 3.2.1 建立测试表test.................................................. 24
 3.2.2 生产环境标准的UTF8格式表结构语句.................. 25
  3.2.2.1 mysql字段类型............................................. 25
  3.2.2.2 建立几个关联表:....................................... 26
  3.2.2.3 创建关联表语句........................................... 26
  3.2.2.4 某sns产品生产正式建表语句....................... 27
3.3 查表结构及建表的SQL.................................................... 27
 3.3.1 查看表结构.......................................................... 27
 3.3.2 查看建表语句....................................................... 28
 3.3.3 为字段创建索引................................................... 28
3.4插入数据......................................................................... 31
3.5 查询............................................................................... 34
 3.5.1 查询所有行............................................................ 34
 3.5.2 查询前几行数据..................................................... 34
 3.5.3 多表查询............................................................... 37
 3.5.4 使用explain查询select语句使用索引情况.............. 37
3.6 修改表中数据................................................................. 38
3.7 删除表中数据................................................................. 39
3.8 在表中增删改字段(dba操作).......................................... 41
3.9 更改表名........................................................................ 43
3.10 删除表.......................................................................... 45
3.11 mysql字段类型............................................................. 45
4 MySQL数据库的备份与恢复........................................................ 45
4.1 准备工作:首先建表填充数据......................................... 45
4.2 填充中文数据暴漏乱码问题............................................ 46
4.3 MySQL字符集介绍........................................................... 50
4.4 set names gbk在做什么?............................................. 52
4.5备份单个数据库............................................................... 57
4.6 mysqldump在做什么?.................................................... 59
4.7备份多个库...................................................................... 61
4.8备份单个表...................................................................... 61
4.9备份多个表...................................................................... 62
4.10备份数据库结构(不包含数据)........................................ 63
5恢复数据库................................................................................ 64
5.1 source命令恢复............................................................. 64
5.2 mysql命令恢复(标准).................................................... 70
6 mysql带-e参数实现非交互式对话............................................... 72
6.1 恢复mysql数据.............................................................. 72
6.2 查看mysql状态.............................................................. 73
7 mysql生产环境案例.................................................................... 76
7.1 mysql数据库批量插入数据shell脚本实现..................... 76
7.2 不登陆数据库执行mysql命令小结.................................. 77

2)视频实战讲解(全屏观看效果更好)

 


 相关视频内容请博友们多多关注老男孩的博客更新。
最后,美国空间,欢迎大家一起探讨学习和教学,如何让学习者有所收获,让从师者如何最大限度的把知识进行最大限度的传承。

本文出自 “老男孩linux运维” 博客,美国空间,香港服务器,请务必保留此出处

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use