How to export data to mysql. Import a MySQL database into the console. Adding Data to MySQL: Tools

When migrating a site from local server for hosting, one of the mandatory procedures is the export/import of the database (database). Therefore, in this article I will try to describe in as much detail as possible the process of exporting and importing a database from a local server, that is, from the web interface PHPMyAdmin version 3.2.3 for hosting.

The first thing to do is start a local server, in this case Denwer. After launching Denwer, you need to open your browser and enter in the browser line: “http://localhost/tools/phpmyadmin”, after which a window will open in front of you(Fig.1)with previously created databases.

Fig.1

Next we need to select the database that we will export, in my case it is a database called Mybd. You can select a database by clicking on it on the left side of the browser window, where it says “Please select a database” (Fig. 2).


Fig.2

After selecting the desired database, a window with the database structure will open. IN top menu there is a point "Export" with the help of which we will export the database to a computer and then import it to the hosting. And so, go to the “Export” item (Fig.3).


Fig.3

In the window that opens you need to make some measurements (Fig.4), namely: in the “Export” block you need to select all database tables by clicking on the item "Select All" and check the box next to the item SQL, this item is responsible for the type of file that will be exported. Also, you need to check the box next to "Save as file", which will ensure that the database is saved in a file. There is no need to change any other settings, just press the button "Go".

Fig.4

Now, if you did everything correctly, the database file should download to your computer. Using this file we will import the database to the hosting.

Also, you need to change the file encoding to UTF-8 without BOM, to change the encoding I use text editor Notepad++(Download ) . Using this program you open the database file and in the menu "Encoding" choose “Convert to UTF-8 without BOM” (Fig. 5), then save and close.


Fig.5

This procedure involves transferring data from one database (A) to another (B). As a rule, database B is located on the hosting (or in Denver), and database A is located on the user’s computer and is a file with the sql extension. Database A has another name - Dump.

How to import a database?

Importing a MySQL Database Using SSH

This method is used quite rarely, but we will describe it. First, fill in the database from which you will import it to the hosting provider’s server, where your website files are stored. Next, to import the database, use the command:

mysql -uUSERNAME -pUSERPASSWORD DBNAME< DUMPFILENAME.sql

mysql --user=USERNAME --password=USERPASSWORD DBNAME< DUMPFILENAME.sql

Instead of words written in capital letters we substitute:
USERNAME - database user name, for example uhosting_databaseuser;

USERPASSWORD - database user password, for example Rjkweuik12;

DBNAME - name of the database into which the import will be made, for example uhosting_databasename

DUMPFILENAME - name of the dump file from which data will be imported. Here we also need to specify the path to the database that we uploaded to the hosting provider’s server.

In this article we will consider two questions - how you can import databases and how to solve the problem with importing large databases by changing the settings in php.ini.

As you know, data backup is a guarantee that you will be able to restore your website if suddenly, for some reason, the operation of the site is disrupted. How to restore a website from a backup? There are several ways, we will look at how you can import a mysql database into phpMyAdmin. Before you begin the database import process, you need to delete all tables from the database into which you are going to import files.

To delete tables, log in to home page phpMyAdmin and do the following:


2 - click Mark all;
3 - select Delete from the drop-down menu and click OK,

Now you can start importing the mysql database. To do this, follow these steps:

1 - select the desired database;
2 - open the Import tab in the top menu;
3 - find through Browse backup copy with the database and click OK.

If you did everything correctly, a message indicating that the import was successful will appear in the phpMyAdmin window.

Importing large mysql databases

Webmasters often encounter the problem of importing large mysql databases. The problem is due to the fact that in PHPMyAdmin, downloading a database dump is limited by the size of the uploaded file, which by default should not exceed 2MB (2,048 KB). When trying to download a dump of a large database, an error message appears: “The download file size is probably too large...” etc.

Let's look at one way to import a dump of a large database. The import file size limit is determined by the PHP configuration. PHP configuration settings are specified in the php.ini file. This means that to import large databases we will need to change the php.ini configuration file maximum size downloaded files.

Where is the php.ini file located? You can calculate the path to the php.ini file as follows:

  • Create an info.php file and place the following code in it;
  • Upload the created file to the root folder of the site (www, public_html);
  • IN address bar browser, enter the address http://your_site/info.php;
  • In the window that opens, find Loaded Configuration File, where the path to the file will be indicated;

To import a large mysql database, you need to change the php.ini directives in PHPMyAdmin.

The php.ini file has been found, now all that remains is to edit it, or rather, change several directives in the file as shown below:

Maximum time (sec) to fully load the script:
max_execution_time = 60
The maximum time (seconds) specified for the script to receive all data:
max_input_time = 90
The maximum amount of memory that the script is allowed to use:
memory_limit = 128M
Maximum allowed size of uploaded files:
upload_max_filesize = 200M
The maximum size of transferred data that PHP will accept:
post_max_size = 180M

By changing the above directives in php.ini, we were able to import via PHPMyAdmin database data volume up to 180 M.

To import a database dump you can also use free version Sypex Dumper programs. The dumper is optimized for maximum speed work, as well as work with databases of about 800 megabytes.

Good afternoon friends, today we will learn how to make... Why is this needed, you may ask. First of all database export must be done periodically in order to emergency situations You have not lost any information that is important to you. The export will be a small file in which all information about the database will be stored. For database export you need to go to PHPMyAdmin and click on the database you are interested in. After this, you will see all the tables in it and, without going into them, click on the menu button called export. The following page will appear in front of you:


I advise you to choose quick way export, and also indicate in the format SQL. After that you can click ok. A window will appear in front of you in which you will be asked to save the file.


You save the file in the location you need, the main thing is to remember where you saved it, because it is very important to us.
As for the normal export method. You can also use it if you need it, there are many additional settings, which you can specify when exporting. For example, select the necessary tables from the database, specify the encoding, and much more. If you are interested this setting, You can watch it. But we will not go deeper into this setting.
After you save the file on your computer, I will ask you to delete the database. I won’t explain to you how to do this, because we have already gone through this. Don’t be afraid to delete, we will return everything to its place with you.
It's time to get busy database import. Go to the import menu.


We select an overview of your computer and indicate the path to our file. And click ok. As you can see, an error has appeared in front of you. Don’t be alarmed, the whole point is that we did not import the database itself, but only all its tables. Therefore, first create a database, go into it and click the import button, having done all of the above. By pressing the ok button, everything will work out, and if you did everything correctly, no errors should appear.


As you can see, our table has reappeared in its place, and all the data in it has been saved. Now you understand what a wonderful opportunity export and import database in PHPMyAdmin. After all, if you lose in one day all your achievements over many years, thanks to this file You can return everything. With this I say goodbye to you and see you soon.

When you just start creating a website, you usually do it on a local server. When it is ready, it will need to be moved to remote server. Copying files is not difficult, but here's how import database to a remote server? Just about how to import a database into PHPMyAdmin, I will explain to you in this article.

There are many ways database import However, I’ll tell you what I think is the simplest one, and the one I use myself.

Step 1

The first thing you need to do is export database from your current location (specifically a local server). Our goal is to get SQL query our database. To do this you need to do the following:

Step 2

The second and final step is to do SQL query, which you copied, to PHPMyAdmin, which is located on the server where you need import database. To do this, follow these steps:

As a result, all your tables with all records will be created on the new server.

As you can see, the process exporting and importing a database in PHPMyAdmin simplified to a minimum, so there will be no problems with this.

Finally, I would like to give you one more piece of advice. The fact is that very often there is a situation when you need do not import the entire database, but, for example, only one table. Then the principle is absolutely the same, only when exporting you need to select not only the database, but also the table to export. And then again in the top menu click on " Export". Then everything is the same database import.