MySQL tutorial import. SQL data implementation several methods
The method is as follows:
1. Connect with Jive User first:
E:mysqlbin>mysql-u jive-p Jive
2. Run the following command again:
Mysql>. F:workingfolderjivejdondatabasejive_mysql.sql
My personal practice is: PHP Tutorial myadmin export utf-8 Insert mode Abc.sql
FTP Abc.sql to Server
SSH to Server
Mysql-u abc-p
Use KKK (Database tutorial name, if not on create DB KKK)
Set names ' UTF8 '
SOURCE Abc.sql
Note: I see set character set UTF8; Saying, that's not good, Chinese garbled.
1. First open MySQL in command line console
Perhaps the order is as follows:
Mysql-u root-p database_name
Then you may be prompted to enter the corresponding password
2. The following command may be useful to you when you want to change a database
Mysql>use database_name
Then use the following command
Mysql>source D:datafilename.sql
Of course you need to figure out the path to the file and use it correctly.
Enter the subdirectory bin of the directory where the MySQL installation resides. Enter the command to execute the import SQL.
For example: Your MySQL is installed in D:mysql
The steps are as follows:
Start-> run-> input cmd
D:
CD Mysqlbin
Mysql-u root-p123456 Test <d:a.sql
Where root is your MySQL administrator username, 123456 for password test d:a.sql the database name to the location of the backed-up data file.
If it is windows, execute the command from the command prompt to the bin folder in the MySQL file directory
Mysql-u root-p DatabaseName < Db.sql
Where root is your MySQL username, DatabaseName is the name of your database, and db.sql you are the file. Note that you must put Db.sql in the Bin folder before you can. The location of the file can be changed.
If it's Linux, enter it directly.
MySQL DatabaseName < Db.sql
On it, system default MySQL command is System command
First, the Operation skill
1, if you hit the command, when you find that you forgot to add a semicolon, you do not need to repeat the command, as long as a semicolon return can be
With a. That is to say, you can divide a complete command into lines, and then use a semicolon as the closing sign to make it OK.
2, you can use the cursor up and down keys to pull up the previous command. But I used to use a MySQL older version does not support. I now
The Mysql-3.23.27-beta-win is in use.
Second, display command
1. Display the list of databases.
show databases;
Only two databases were initially: MySQL and test. MySQL Library is very important it has MySQL system information, we change the secret
Code and new users, is actually using this library to operate.
2, display the data table in the library:
use MySQL;//open library, learned foxbase must be no stranger
Show tables;
3, display the structure of the data table:
describe table name;
4, build the library:
Create database library name;
5, the establishment of the table:
Use library name;
CREATE TABLE table name (field set list);
6, delete the database and delete the table:
drop Database library name;
The drop table table name;
7. Empty the record of the table:
Delete from table name;
8, display the records in the table:
SELECT * from table name;
Example of 三、一个 and table-building and inserting data
Drop database if exists school; Delete if there is school
Create Database School; Build a library School
Use school; Open Library School
CREATE TABLE teacher//Create tables Teacher
(
ID int (3) auto_increment NOT null primary key,
Name Char (a) NOT NULL,
Address varchar default ' Shenzhen ',
Year Date
); Build Table End
The following is the Insert field
Insert into teacher values (', ' Glchengang ', ' Shenzhen One ', ' 1976-10-10 ');
Insert into teacher values (', ' Jack ', ' Shenzhen One ', ' 1975-12-23 ');
Note: In the table (1), set the ID to a number field of length 3: Int (3) and let it automatically add one for each record: Auto_inc
Rement cannot be empty: not
Null and let him be the primary field primary
Key (2) sets the name to the character field (3) with a length of 10 to set the address to the character field of length 50, and the default
Value is Shenzhen. What is the difference between varchar and char, only to wait for later articles to say. (4) Set year as date word
Paragraph
If you type the above command at the MySQL prompt, it's not easy to debug. You can write the above command as a
A text file is assumed to be school.sql, and then copied to C: and into the directory Mysqlbin in DOS state,
Then type the following command:
Mysql-uroot-p Password < C:school.sql
If successful, there is no display on a single line, and if there is an error, there is a hint. (The above command has been debugged, you only have to
Annotations are removed and can be used).
Iv. transferring text data to a database
1, the text data should conform to the format: The field data is separated by the TAB key, null value with N to replace.
Cases:
3 Rose Shenzhen II 1976-10-10
4 Mike Shenzhen one 1975-12-23
2, Data incoming command load infile "filename" into table name;
Note: You'd better copy the files to the Mysqlbin directory and use the using command to hit the library where the table resides.
V. BACKUP DATABASE: (command executes in DOS Mysqlbin directory)
Mysqldump--opt SCHOOL>SCHOOL.BBB
Note: Back up the database school to the school.bbb file, school.bbb is a text file, file name to take, hit
Take a look and you'll find something new.