一、Mysql安装目录
数据库目录:/var/lib/mysql/
配置文件:/usr/share/mysql(mysql.server命令及配置文件)
相关命令:/usr/bin(mysqladmin mysqldump等命令)
启动脚本:/etc/init.d/mysql(启动脚本文件mysql的目录)
二、系统管理
代码如下:
hadoop@ubuntu:~$ mysql -uroot -pmysql;
例 2:连接到远程主机上的MYSQL。
代码如下:
hadoop@ubuntu:~$ mysql -h 127.0.0.1 -uroot -pmysql;
代码如下:
mysql>grant select,insert,update,delete on *.* to root@localhost identified by 'mysql';
或者
代码如下:
grant all privileges on *.* to root@localhost identified by 'mysql';
然后刷新权限设置:flush privileges;
例 2:如果你不想 root 有密码操作数据库“mydb”里的数据表,可以再打一个命令将密码消掉。
代码如下:
grant select,insert,update,delete on mydb.* to root@localhost identified by '';
代码如下:
mysql> drop table MyClass;
代码如下:
mysql> insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);
代码如下:
mysql> select * from MyClass order by id limit 0,2;
或者
代码如下:
mysql> select * from MyClass limit 0,2;
代码如下:
mysql> delete from MyClass where id=1;
代码如下:
mysql> update MyClass set name='Mary' where id=1;
代码如下:
mysql> alter table MyClass add passtest int(4) default '0'
代码如下:
mysql> rename table MyClass to YouClass;
代码如下:
update article set content=concat(' ', content);
五、数据库导入导出
从数据库导出数据库文件使用“mysqldump”命令,首先进入 DOS 界面,然后进行下面操作。
1)导出所有数据库
格式:mysqldump -u [数据库用户名] -p -A>[备份文件的保存路径]
2)导出数据和数据结构
格式:mysqldump -u [数据库用户名] -p [要备份的数据库名称]>[备份文件的保存路径]
举例:
例1:将数据库 mydb 导出到 e:\MySQL\mydb.sql 文件中。
打开开始->运行->输入“cmd”,进入命令行模式。
c:\> mysqldump -h localhost -u root -p mydb >e:\MySQL\mydb.sql
然后输入密码,等待一会导出就成功了,可以到目标文件中检查是否成功。
例2:将数据库 mydb 中的 mytable 导出到 e:\MySQL\mytable.sql 文件中。
c:\> mysqldump -h localhost -u root -p mydb mytable>e:\MySQL\mytable.sql
例3:将数据库 mydb 的结构导出到 e:\MySQL\mydb_stru.sql 文件中。
c:\> mysqldump -h localhost -u root -p mydb --add-drop-table >e:\MySQL\mydb_stru.sql
备注:-h localhost 可以省略,其一般在虚拟主机上用。
3)只导出数据不导出数据结构
格式:
mysqldump -u [数据库用户名] -p -t [要备份的数据库名称]>[备份文件的保存路径]
4)导出数据库中的Events
格式:mysqldump -u [数据库用户名] -p -E [数据库用户名]>[备份文件的保存路径]
5)导出数据库中的存储过程和函数
格式:mysqldump -u [数据库用户名] -p -R [数据库用户名]>[备份文件的保存路径]
从外部文件导入数据库中
1)使用“source”命令
首先进入“mysql”命令控制台,然后创建数据库,然后使用该数据库。最后执行下面操作。
mysql>source [备份文件的保存路径]
2)使用“
首先进入“mysql”命令控制台,然后创建数据库,然后退出 MySQL,进入 DOS 界面。最后执行下面操作。
mysql -u root –p
以上就是Mysql常用命令汇总,希望对大家的学习有所帮助。

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
