MySql dump操作教程

版权声明:转载 MySql dump操作教程 时请以超链接形式标明文章出自 正确的方法 !!!

How do I access MySQL using SSH?

To Access MySQL Using SSH (Plesk not installed) Log on to your server. At the command line, type su –. This gives you root access. At the command line, type mysql -uroot -p Enter your MySQL root password. NOTE: MySQL’s default root password is an empty string (no password is set).

作者 海云青飞:传统文化第一人。著有 《悟道相对论》。 微信扫描,关注公众号,一站式解决你的所有人生疑惑:

How do I reset my MySQL Password on my Dedicated Linux Server?

To stop MySQL and restart in safe mode: At the command prompt, type the following commands and press Enter after each.

service mysqld stop
killall mysqld
mysqld_safe --skip-grant-tables&

To reset the admin password and permissions: At the command prompt, type the following command and press Enter.

mysql psa -e “flush privileges; grant all privileges on . to ‘admin’@‘localhost’ identified by "password” NOTE: Replace “password” with you Plesk or cPanel administrative password.

To stop safe mode and restart MySQL: At the command prompt, type the following commands and press Enter after each.

killall mysqld
service mysqld start

MySql 数据库自动备份脚本 Mysqldump is really a horrible way to backup a mysql database. It is a debugging, development, and migration tool, not a backup tool. It won’t even get you a coherent snapshot of the entire database at one time and it’s SLOOOOOOOOOW as a dog.

There are plenty of ways to do it “properly” but the simplest to explain is to just do a LOCK TABLES on all databases then do a file copy of the actual data in /var/lib/mysql (or whereever you have it). If you want to avoid any downtime at all, you can lock the tables and perform the backup from a seperate mysql server replicated from your primary data store. If you don’t want to run a second machine or second mysql server on the same machine and you can incur a second or two of downtime, you can put your data store onto an LVM or EVMS volume, LOCK TABLES, snapshot the disk, UNLOCK TABLES then backup from the volume snapshot. The LVM approach is a very elegant single-server approach that is straightforward and free.

There are also several commercial and noncomemrcial mysql backup solutions that do database snapshot/backup properly as well such as the InnoDB hot backup mentioned above. Open notepad and turn word wrap off. (using this is optional, read all before proceeding)

GoDaddy空间 Mysql 操作

Log into your godaddy hosting control panel. Click on the mysql icon or tab. Select the database (DB) that you need to dump. Click on the open manager button. You will need to know the mysql username and password for the account. Enter them and click the button. This opens phpmyadmin. Click on the export link to dump the entire DB. Note that very large DBs may have to be dumped in sections. If in doubt try it. Make sure the sql button is selected Select SQL compatibility mode 4.xx is the most common. Under Structure I always check Add DROP TABLE Add IF NOT EXISTS This will drop existing tables and add them if they are not in the DB. Click the go button and wait for the screen to refresh. Copy the all text in the white box that starts with — phpMyAdmin SQL Dump to the bottom of the window. Paste that into your open notepad and save it as DBname.sql using all files . If it gets saved as a .txt no big deal.

You can also use the save as option at the bottom of the page on the left to save it to your local computer, but I like seeing the output which is why I do it the above way.

Now if you are not going to be able to get back there this is a good time to go ahead and dump it in a couple of more formats for backup. CSV, XML and Excel if you have it. These can be parsed with the correct software to recreate the database if need be.

Be sure to logout.

For the new server create a new database and you should be able to import the file directly from your local machine using the import button.

Some scripts, like wordpress store mail server information in some of the tables and the dump should be updated before it is restored.

If you don’t already have a copy of notepad2 this is a great time to download a free copy as it will let you open files.sql and save them with no hassle.

MySql dump命令的使用

mysqldump -h82.45.32.01 -uroot -pmypassword –opt name>name.sql

mysqldump -uroot -pmypass name < name.sql

用mysqldump对MySQL数据库进行数据备份与恢复2007-12-05 15:09数据库备份是很重要的。如果定期做好备份,这样就可以在发生系统崩溃时恢复数据到最后一次正常的状态,把损失减小到最少。MySQLl提供了一个mysqldump命令,我们可以用它进行数据备份,下面假设要备份tm这个数据库:

#mysqldump -u root -p tm > tm_050519.sql


#mysqldump -u root -p tm | gzip > tm_050519.sql.gz


#mysql -u root -p tm < tm_050519.sql


#gzip < tm_050519.sql.gz | mysql -u root -p tm

导入数据库 常用source 命令 进入mysql数据库控制台, 如

mysql -u root -p 
mysql>use 数据库


mysql>source d:\wcnc_db.sql
MySql dump操作教程