Перенос mysql linux на windows

mySQL performance has been ridiculously latent on a shared web hosting site. So basically I moved the live database to a standalone Windows lab server where i can assess mySQL query performance in a more controlled environment where those measurements are not tangled by other virtual web servers on the same machines. Now that i have worked through the kinks on my own and refined each step, I would like to share them with you.

Please do not follow this procedure,if you have existing tables in the database that you want to preserve on your test server. I’m not accountable for your loss of data. Always backup data safely to a non-working directory before messing with single-copied-data.

    On Windows server

1. Download latest mysql server for windows OS. Make sure to set a strong password for the root account during setup process.

http://dev.mysql.com/downloads/

2. After installation is completed and MYSQL service has started successfully, login as root to mysql server.

C:\mysql –user=root -p

3. Verify you are logged in to Win32 mysql as root.

mysql> \s
————–
mysql Ver 14.14 Distrib 5.5.13, for Win32 (x86)

Connection id: 6
Current database: mysql
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.13 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 10 min 56 sec

Threads: 1 Questions: 15 Slow queries: 0 Opens: 33 Flush tables: 1 Open tab
les: 26 Queries per second avg: 0.22

4. Create a new account with sufficient privileges to import a database. All privileges is way sufficient for a Database Administrator. Please specify something more granular for untrusted users. A list of supported privileges are listed at http://dev.mysql.com/doc/refman/5.0/en/grant.html. For sake of demonstration only specify all. Specifying all does not grant any authority to create other accounts; although you could grant such authority using key word ‘with’. Please refer to dev.mysql.com for usage details.

mysql> CREATE USER usernamehere@localhost
-> IDENTIFIED BY ‘mypasswordhere’;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all ON *.* to usernamehere@localhost;
Query OK, 0 rows affected (0.00 sec)

5. Verify new account is present in user table; mysql is the database name and user is the table name. Each part is separated by a period.

mysql> select Host,User,Create_priv from mysql.user;
+———–+———-+————-+
| Host | User | Create_priv |
+———–+———-+————-+
| localhost | root | Y |
| 127.0.0.1 | root | Y |
| ::1 | root | Y |
| localhost | | N |
| localhost | usernamehere | Y |
+———–+———-+————-+
5 rows in set (0.00 sec)

mysql>

6. Validate login to mysql Win32 with the new account.

C:\MySQLServer5.5\bin> mysql –user=usernamehere –password
Enter password: **********

mysql> \s
————–
mysql Ver 14.14 Distrib 5.5.13, for Win32 (x86)

Connection id: 8
Current database:
Current user: usernamehere@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.13 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 36 min 9 sec

Threads: 1 Questions: 28 Slow queries: 0 Opens: 34 Flush tables: 1 Open tab
les: 1 Queries per second avg: 0.12
————–

mysql>

7. Create new database that reflects same database name from the UNIX server.

mysql> create database yahoo_GLOBAL;
Query OK, 1 row affected (0.05 sec)

8. Verify database exist

mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| yahoo_global |
| mysql |
| performance_schema |
| test |
+——————–+
5 rows in set (0.01 sec)

mysql>

    On UNIX/LINUX server

9. Make a backup copy of mysql database

mysqldump -u username -p dbnamedb > dbnamedb

10. Move original mysql database file from UNIX server to bin folder where mysql.exe now resides on the Windows server. SSH and FTPS are secure transfer protocols that safely move files from one server to another.

    On Windows server

11. Import database into mysql Windows server

C:\MySQLServer5.5\bin>mysql -u usernamehere -p yahoo_GLOBAL < yahoo_global
Enter password: **********

12. Test import of database into Windows mysql.

mysql> connect ertechno_GLOBAL
Connection id: 30
Current database: ertechno_GLOBAL

13. Validate tables are present and rows are countable.

mysql> show tables;
—————————+
Tables_in_yahoo_global |
—————————+
table1_29 |
table2_30 |
commentary |
socialuser |
sectionbysectionstats |
useraccounts |
sale_transactions |
—————————+
rows in set (0.17 sec)

mysql>

mysql> select count(counter) as “total” from table1_29 ;
+———+
| total |
+———+
| 1679198 |
+———+
1 row in set (1.92 sec)

14. That’s it

About da’ IT essentials blogger

Hobbies: family, PHP scripting, exercising, blogging, charity, networks,and art collecting.

1) Yes: you can absolutely import a MySql database from Linux to Windows. And yes, a dump file is absolutely the best way to do it :)

2) The question is «why am I getting Mysql error 1105 on import»?

3) Unfortunately, this error is somewhat generic. There are many different possible root causes.

The link you cited gives many different reasons:

  • http://forums.mysql.com/read.php?22,19755,305448#msg-305448

    For example:

In my case, the problem was that the referenced field was not marked
as unique, and thus returned this (unrelated) error message.

SUGGESTION:

Identify the specific table, cut/paste the sql dump command directly into mysql, and debug that way.

ADDENDUM:

1) Please cut/paste the exact error message.

If possible, please

2) cut/paste the SQL line in your dbexport that’s causing the error.

Добрый день, коллеги.

Раньше всегда пользовался услугами виртуального хостинга на линуксе, с недавних пор использую VPS на Windows Web Server для разных задач, решил и перенести сайты со старого хостинга на этот VPS.

В данном случае я переносил сайт на движке WordPress. В общем все на самом деле просто и командной строкой не пользовался, заодно узнал, что такое MySQL WorkBench.

Итак, процедура состоит в следующем (один из вариантов так сказать):

1. Делаем дамп базы через PHPMyAdmin в файл dump.sql

2. Дамп переносим на VPS.

3. Через платформу Web Platform Installer устанавливаем WordPress, MySQL, PHP

4. Скачиваем и устанавливаем MySQL WorkBench (конечно можно обойтись и без него, делать все операции можно через командную строку)

5. Поскольку платформа сразу создает базу данных для wordpress, нужно из нее удалить таблицы, иначе при импорте появится ошибка #1062. Для этого в MySQL WorkBench нажимаем дважды на Local instance MySQL, откроется новое окно, выбираем нашу базу, далее
tables, выделяем все таблицы и выполняем команду drop table. Теперь база пуста.

6. Далее в главном окне нажимаем Manage Import\Export, переходим в Import, указываем базу и нужный файл, жмем Start, смотрим лог, никаких ошибок быть не должно.

7. Открываем и проверяем сайт.

I would like to copy a MySQL database form Linux to Windows, from a little research I found this url http://www.cyberciti.biz/tips/howto-copy-mysql-database-remote-server.html where the author says we could copy MySQL Database using the following command in Linux

Linux to Linux

mysqldump -u username -p 'password' db-name | ssh [email protected] mysql -u username -p 'password' db-name

Is there a command for copying MySQL database from Linux to Windows?

asked Mar 4, 2013 at 18:05

unknown's user avatar

5

Linux -> Windows you have two obvious options.

  1. Setup a SSHD on your Windows machine and use the above command (mysql binary would need to be in your search path under Windows).

  2. Configure your root (or similar privileged account) to access your Windows MySQL host over network then do:

mysqldump -u username -p 'password' db-name | mysql -h windowsip -u username -p 'password' db-name

Unfortunately with #2, if you have complex indicies (or huge tables) you’ll have issues with net_read_timeout on your Linux host. For most situations I would expect this to just work, though.

answered Mar 5, 2013 at 23:30

TomA's user avatar

Проще всего сделать mysqldump на вашем linux-сервере, а затем импортировать указанный дамп в вашу локальную базу данных Windows.

Во-первых, mysqldump (документы: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)

mysqldump -u [username] -p [any other options desired] [database name] > dump.sql

Вышеприведенный файл создает файл с именем «dump.sql» в каталоге, в котором вы его запустили. Затем возьмите этот файл dump.sql из вашего linux-бокса и перенесите его в ваш windows-бокс. Теперь вы можете использовать графический интерфейс для импорта дампа (например, navicat или sqlyog, или даже phpmyadmin, если вам это нужно), но обычно вы делаете это из командной строки (в linux вам, возможно, придется сделать регулировка на окнах) это:

mysql -u [username] -p < dump.sql

И это все! Приведенная выше строка направляет файл dump.sql в mysql. Файл дампа — это не что иное, как набор операторов SQL, поэтому вышесказанное работает. Извините за то, что не смог предоставить специфичные для Windows инструкции командной строки, я давно работал с windows:) Надеюсь, это поможет.

  • Переместить пуск в сторону windows 11
  • Перенос mbr на другой диск windows 7
  • Перенос windows 10 с hdd на ssd paragon
  • Перенос windows на ssd aomei partition assistant
  • Перенос firefox из windows в linux