Home Database Mysql Tutorial 实现MySQL备份和还原在Win32下

实现MySQL备份和还原在Win32下

Jun 07, 2016 pm 04:14 PM
mysql win32 backup accomplish article reduction

以下的文章主要是对在Win32下实现MySQL备份和还原的实际操作步骤,以下的文章就有此实际操作方案的介绍,相信如果你掌握了这项技术,会在以后的学习或是工作中带来很大的帮助。 1.Win32下MySQL备份与还原 1.1 MySQL备份 开始菜单 | 运行 | cmd |利用cd \Prog

以下的文章主要是对在Win32下实现MySQL备份和还原的实际操作步骤,以下的文章就有此实际操作方案的介绍,相信如果你掌握了这项技术,会在以后的学习或是工作中带来很大的帮助。

1.Win32下MySQL备份与还原

1.1 MySQL备份 开始菜单 | 运行 | cmd |利用“cd \Program Files\MySQL\MySQL Server 5.0\bin”命令进入bin文件夹 | 利用“mysqldump -u 用户名 -p databasename >exportfilename”导出数据库到文件,如mysqldump -u root -p voice>voice.sql,然后输入密码即可开始导出。

1.2 还原 进入MySQL Command Line Client,输入密码,进入到“mysql>”,输入命令"show databases;",回车,看看有些什么数据库;建立你要还原的数据库,输入"create database voice;",回车;切换到刚建立的数据库,输入"use voice;",回车;导入数据,输入"source voice.sql;",回车,开始导入,再次出现"mysql>"并且没有提示错误即还原成功。 2.Linux下MySQL的备份与还原

2.1 MySQL备份 [root@localhost ~]# cd /var/lib/mysql (进入到MySQL库目录,根据自己的MySQL的安装情况调整目录) [root@localhost mysql]# mysqldump -u root -p voice>voice.sql,输入密码即可。

2.2 还原

法一: [root@localhost ~]# mysql -u root -p 回车,输入密码,进入MySQL的控制台"mysql>",同1.2还原。

法二: [root@localhost ~]# cd /var/lib/mysql (进入到MySQL库目录,根据自己的MySQL的安装情况调整目录) [root@localhost mysql]# mysql -u root -p voice绿色版 MySQL 的安装配置

本人下载的MySQL是5.1版的

下载 免安装包(mysql-noinstall-5.1.45-win32.zip)

解压该压缩文件到E:\mysql-5.1.39-win32

1.在系统环境变量path中添加 E:\mysql-5.1.39-win32\bin (注:这是本人的MySQL安装路径)

2.编辑mysql备份的运行配置文件my.ini,如果没有,可以拿my-medium.ini复制然后更名成 my.ini

分别copy一份到E:\mysql-5.1.39-win32和 C:\WINDOWS 中

编辑该文件my.ini文件

[mysqld]

# 设置mysql的安装目录

basedir=E:/mysql-5.1.39-win32/

# 设置mysql数据库的数据的存放目录,必须是data,或者是\\xxx\data

datadir=E:/mysql-5.1.39-win32/data

# 设置mysql服务器的字符集

default-character-set=utf8

[client]

# 设置mysql客户端的字符集

default-character-set=gbk

注:分割线中的配置为可选,可以在建立数据库的时候自行设置。

3.安装mysql服务

从MS-DOS窗口进入目录E:\myserver\mysql-5.0.37-win32\bin,运行如下命令:

mysqld --install mysql5 --defaults-file=C:\WINDOWS\my.ini

其中,mysql5 只是该服务的名字,可以自己另外设置,比如改为 xiaomai

即:mysqld --install xiaomai --defaults-file=C:\WINDOWS\my.ini

4.启动mysql数据库

还在上面的命令窗口里面,输入命令:net start mysql5

这样就启动了mysql 服务。

5.停止服务

执行 net stop mysql5 即可

6.以上5步安装完毕之后,MySQL默认的root用户密码为空的。

可以设置一下root的密码:

win+R -> 输入cmd->打开windows命令控制台,随意定位文件目录,如下

<ol class="dp-xml">
<li class="alt"><span><span>E:\erlangPro\mysqlTest\src</span><span class="tag">></span><span>mysql -u root -p  </span></span></li>
<li><span>Enter password:  </span></li>
<li class="alt"><span>Welcome to the MySQL monitor. Commands end with ; or \g.  </span></li>
<li><span>Your MySQL connection id is 8  </span></li>
<li class="alt"><span>Server version: 5.1.39-community MySQL Community Server (GPL)  </span></li>
<li><span>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  </span></li>
<li class="alt">
<span>mysql</span><span class="tag">></span><span> use mysql  </span>
</li>
<li><span>Database changed  </span></li>
<li class="alt">
<span>mysql</span><span class="tag">></span><span> update user set </span><span class="attribute">password</span><span class="attribute-value">password</span><span>=password('admin') where </span><span class="attribute">user</span><span>=</span><span class="attribute-value">'root'</span><span>;  </span>
</li>
<li><span>Query OK, 2 rows affected (0.03 sec)  </span></li>
<li class="alt"><span>Rows matched: 2 Changed: 2 Warnings: 0  </span></li>
<li>
<span>mysql</span><span class="tag">></span><span> </span>
</li>
</ol>
Copy after login

退出MySQL,重启MySQL服务即可

以上的相关内容就是对Win32下MySQL备份与还原 的介绍,望你能有所收获。


Statement of this Website
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the &quot;MySQL Native Password&quot; plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles