How to Use navicat for mysql to connect to a local database and import data files
How to Use navicat for mysql to connect to a local database and import data files
1. Introduction
Navicat for mysql is a database management tool designed to simplify, develop, and manage MySQL. We can use navicat for mysql to connect to a remote database or a local database. You can use this tool to conveniently View table data. You can also enter an SQL command to perform queries. However, it is not convenient to enter commands such as create table. Let's take a look at how to use navicat for mysql to create and query data in the database.
2. Connect to the database
First, make sure that you have installed MySQL Server 5.1 and navicat for mysql. This installation is very simple. There are many tutorials on the Internet, which are similar to installing common software. Only when installing MySQL Server 5.1, You must select the character encoding gb2312 (Chinese) option. Well, I won't talk about installation here.
After installation, open MySql Commend Line Client and enter the password, for example:
Now we enter the MySql Command window. Here we can create a database and a table:
mysql> create database mydata;mysql> use mydata;mysql> create table StudentScore -> (name varchar(10) primary key, -> number int(10), -> department varchar(10), -> gender varchar(10), -> birth int(10), -> score int(10) -> );
The result is as follows:
The above commands have already created a mydata database with a StudentScore table. The table contains the following columns: name, number, department, gender, birth, score. each type and primary key are also defined.
3. Use navicat for mysql to import data files
Open navicat for mysql and connect to the localhost local database. We can see the database and table we just created, for example:
We can import local txt data files, as shown in the following figure: (I have not studied it very deeply. I have been using remote databases all the time before. I tried importing local txt files. Yes, make sure that the format is correct)
Note that if your database contains Chinese data, You must select GB2312. for example:
The Delimiter is a space (based on the specific circumstances in the txt file ). Select the target table and match each column to import the table, for example: