linux下Mysql 的安装、配置、数据导入导出
MySQL 是一种 开放源代码 的关系型 数据库管理 系统(RDBMS), 虽然功能未必很强大,但因它的免费开源而广受欢迎。 CSDN写日志总有问题,直接到这里看吧;http://www.cnblogs.com/alylee/p/MySql_Setup_Init.html 一、安装准备 下载得到安装包很简单。 1、rp
MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),虽然功能未必很强大,但因它的免费开源而广受欢迎。
CSDN写日志总有问题,直接到这里看吧; http://www.cnblogs.com/alylee/p/MySql_Setup_Init.html
一、安装准备
下载得到安装包很简单。
1、rpm安装:A、在linux下使用wget获取 B、在虚拟机所在的宿主机windows下,在网络上下载Rpm安装包,然后通过之前我们配置的samba共享目录拷贝到centos下。
单独下载要注意你需要的rpm包:
1 2 3 4 |
|
2、yum 在线安装:使用CentOs的Yum(如果有特定的Mysql版本需求,要确定你的Yum库里有需要的mysql版本)
1 2 3 4 5 6 7 8 |
|
二、安装Mysql
检测当前系统是否已经安装了mysql :运行下面的命令,如果已经安装过,会显示mysql的版本信息。
1 |
|
如果已经安装过mysql,但是不是自己需要的版本,比如需要高版本的mysql对事件的支持等,怎么办?删除呗!注意,这可能会删除一些相关的依赖库而影响到其他软件,不过可以重新安装。
1 |
|
1、rpm安装:
1 2 3 |
|
2、yum安装:
1 2 3 |
|
这里注意:
A、根据你的开发环境需要,你可以选择对应的rpm包。你可以在命令行,使用"yum search mysql"搜索与mysql有关的安装包,从中选择你需要的。如果你记不住名字也可以这样搜索下。
1 |
|
B、上面列出rpm包名字和简介,还可以通过yum info获取具体rpm包的具体的版本信息
1 2 3 4 5 6 |
|
三、Mysql初始配置
刚刚安装好的mysql需要进行一定的配置,才适合使用。
1、设置Mysql开机启动
1 2 3 |
|
1 2 |
|
chkconfig,如果不知道是干什么的,那现在来了解下
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 5 6 7 8 |
|
2、Mysql服务的启动/关闭/重启
1 2 3 |
|
3、安全设置
1 2 3 4 5 6 7 8 9 |
|
4、测试
登陆:
1 2 3 4 |
|
sql操作:
1 2 3 4 5 6 7 8 |
|
5、NaviCat远程连接的权限问题
1 |
|
1 2 3 |
|
解决方案:
1 2 3 4 |
|
四、数据库和表的导入、导出
1.导出整个的数据库:mysqldump -u 用户名 -p 数据库名 > 导出的文件名
mysqldump -u root -p db_test >/home/bak/dbtest.sql
2.导出指定数据库中的一个表:mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
mysqldump -u root -p db_test tbl_user >/home/bak/test_user.sql
3.只导出一个结构(struct):加上-d参数
mysqldump -u root -p -d –add-drop-table db_test >/home/bak/dbtest_struct.sql
4.只导出一个数据(data):加上-t参数
mysqldump -u root -p -t –add-drop-table db_test >/home/bak/dbtest_struct.sql
1 2 3 4 5 6 7 |
|
-t 不导出结构,只要数据
–add-drop-table 在每个create语句之前增加一个drop table
–default-character-set 设置字符集
②.这里的导出文件没有加路径,就是相对路径,当前的目录下的文件。
③.密码是显示输入的,跟在-p后面。
5.导入数据库:source 命令
1 2 3 |
|
!
作者:子韦一

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

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Docker is important on Linux because Linux is its native platform that provides rich tools and community support. 1. Install Docker: Use sudoapt-getupdate and sudoapt-getinstalldocker-cedocker-ce-clicotainerd.io. 2. Create and manage containers: Use dockerrun commands, such as dockerrun-d--namemynginx-p80:80nginx. 3. Write Dockerfile: Optimize the image size and use multi-stage construction. 4. Optimization and debugging: Use dockerlogs and dockerex

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

CentOS is the first choice for server and enterprise environments for its superior security, stability and performance. 1) Security provides forced access control through SELinux to improve system security. 2) Stability is supported by the LTS version for up to 10 years to ensure the stability of the system. 3) Performance significantly improves system response speed and resource utilization by optimizing kernel and system configuration.
