Some experiences of learning mysql

xiaoxiao2021-03-06  95

1. Window2000 installation. A. The installation directory is best (it should be necessary) is C: /, before, there is no clear explanation, installed in the D disk, the result can't start. B. Install to start the service: mysqld-nt --install Uninstall Service: mysqld-nt --uninstall Remove Service: MySQLD-NT - Remove Start Service: Net Start MySQL Stop Service: Net Stop MySQL2. Connection and User Management A. Connection Mysql Database: mysql -h host -u user -p login with root: mysql -h localhost -uroot -p B. Disconnect: Quit or Exit C. New users (username Tom, password 123 : Connect to the database with root, then use the following command: grant all privileges on *. * To

'Tom' @ 'Localhost'

Identified by '123' with grant option; or grant all privileges on *. * to

'Tom' @ '%'

Identified by '123' with grant option; or Insert INTO User Values ​​('localhost', 'Tom', Password ('123'), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y'); MYSQL creates an automatic number field in MySQL: Create Table `Table1` ( `ID` int (6) unsigned not null auto_increment, primary key (` ID`) (one of Int, can you, whene_increment)

In a mysql table, if there is already 10,000 records, how can it be started from 1, not from 10001!

Truncate your_table;

Alter Table your_table auto_increment = 1;

Mount data into a database table with text

If a one is entered, it is very troublesome. We can add all records in your database table with text files.

Create a text file "mysql.txt", each line contains a record, separated by the locator (Tab), and

The column sequence listed in the CREATE TABLE statement is given, for example:

Abccs f 1977-07-07 China

Mary F 1978-12-12 USA

Tom M 1970-09-02 USA

Use the following command to load the text file "myTable.txt" into myTable table:

MySQL> Load Data local infile "MyTable.txt" INTO TABLE PET;

Execute SQL scripts: Myql> Source D: /aa.sql

Mysql Data Export and Import: Reference article: MySQL Data Import Export Method and Tool Introduction http://blog.9cbs.net/davidullua/archive/2004/04/26/21980.aspx http://blog.9cbs.net/ Davidullua / Archive / 2004/04/26 / 21981.aspx http://blog.9cbs.net/davidullua/archive/2004/04/26/21982.aspx main tools: mysqldump.exe, mysqlimport.exe and mysql.exe The three are in the mysql / bin directory. Mysqlcc.exe Additional Installation (1) Export 1, Structure Export (1) In MySQLCC, select a table or Tables, press Shift or mouse zip, select "Tool / Show Create" in the shortcut menu. Select You have to export the table (can be selected, Ctrl a all) Click Execute below the form. You can generate a SQL file of the selected table structure. Open the SQL query window and stick to the SQL script generated above. All table structures can be generated in the new location. (2) MYSQLDUMP.EXE specific parameters, you can view - Hostname -u username -p password - ADD-DROP-TABLE This option will be added to the Drop Table if Exists statement in front of each table This will not be wrong when the Mysql database is guided, because each time is returned, will first check if the table exists, and the existence is deleted - ADD-LOCKS This option will be bundled on the Insert statement on a Lock Table and UNLOCK TABLE statement. This prevents the operation of other users on the table when these records are again imported into the database.

-c or - complete_insert This option makes mySQLDUMP commands to each generated an Insert statement to add (Field) name. This option is useful when you export the data.

-f or -force uses this option, even if there is an error, continue to export

-l or -lock-tables Use this option to export the server, the server will lock the table. -T or -no-create- info This option makes the mysqldump command not to create a CREATE TABLE statement. This option is convenient when you only need data without a DDL (database definition statement).

-d or-dia-data This option makes the mysqldump command does not create an Insert statement. This option can be used when you only need DDL statements.

-T path or -tab = path This option will create two files, one file contains DDL statements or table creation statements, and another file contains data. The DDL file is named Table_Name.sql, and the data file is named Table_name.txt. The path name is the directory where these two files are stored. The directory must already exist, and the user has the privilege of the file.

-w "where clause" or -where = "where clause" can use this option to filter the data that will be placed in the export file. (3) Mysql.exe uses the Select Into Outfile syntax to export data to an external file. Specific grammar is slightly. (2) Import 1, structure (1) mysqlcc Open the SQL query window and stick into the SQL script generated above. All table structures can be generated in the new location. (2) MySQLIMPORT can be used to load data (3) mysql.exe bin / mysql -p

Or open a CMD window, type mysql E: /work/backup/gezhi211javatest.txt (2) In the forefrunks of statement, add the following sentences of DROP DATABASE IF EXISTS JAVATEST; CREATE DATABASE JAVATEST; use javate; used to create database javatest (3) Import data mysql -p

MySQL changed to the UTF8 character set, started by named line parameters:

MySQLD - DEFAULT-CHARACTER-SET = UTF8

转载请注明原文地址:https://www.9cbs.com/read-96169.html

New Post(0)