DOS telnet to MySQL database

Source: Internet
Author: User
Tags table name create database mysql database

Into the MySQL bin directory of this machine, remember that it is the machine! Create a text document

mysqldump-h127.0.0.1-uroot-p123456 Diguang > Diguang.sql means to make the native Diguang database a diguang.sql script, and the native database user is root The password is 123456, you only need to modify the database user and password, as well as the database name!

Mysqldump This is an order, according to write can, do not change,-h127.0.0.1 this is the meaning of this machine, according to write can

-uroot This is the MySQL user name of this computer can be written, without modification,

-p123456? This is the local password note-P is the password,-p after the password is 123,456 only need to change this 123456 to your local MySQL password,

Diguang This is my local database name, meaning I'm going to make that database a SQL script, Diguang.sql This is where I put the generated SQL script, and what's the name of the script

Notice the space inside, save and exit, find the newly created text document. txt, and modify it to a new text document. bat

Modified to become

Double-click it to generate the local database SQL script, we first copy the generated to the C disk, easy to find this script.

Build script is ready, now we need to publish the script we just generated to the remote database! And then look down.

In the Start menu, enter the cmd after the operation of the point to determine, or press ENTER.

Input mysql-h58.222.24.35-uziiiij-pjjwgynif Note the space inside

Mysql This is an order, no modification

-h58.222.24.35? This is the database extranet IP, the IP in this to exchange your remote database IP can be

-uziiiij This is the user name of your remote database. Remember, only----You can change the ziiiij here for you.

-pjjwgynif This is the password for your remote database, and the modification of

Don't tell me you don't know what your database IP and database name and password are ... If you really forget to look here

Enter the above database IP and database user and password and press ENTER to connect to the remote database

Note that it is sometimes suggested that MySQL is not an external or internal command!

To encounter such a problem, please set your computer's system variables

System variable settings. "My Computer--attributes--advanced-environment variables", in the system variables found path, add "E:mysqlbin", OK

Here's the e:mysqlbin is your mysqlbin specific path, please according to own installation directory modification, completes the system variable setting, after executes the above step

You can connect remotely after a carriage return, as shown

This is successful, if not connected, please modify the database password in the background after the attempt to login, or check whether the user name and password did not input good, or check the location of space, carefully and the picture on the

Continue to enter use Ziiiij on the console

ZIIIIJ is your remote database name, here's to your

In the picture below, I intentionally entered the name of the wrong remote database. He will prompt the error, the input is correct, he will prompt the database changed said to be successful!

The above can be internship published database.

If you want to delete a database, or delete a table in the database, or all the data entries in the table. How to input instructions.

MySQL remote login and Common commands

First recruit, MySQL service start and stop net stop MySQL

net start MySQL

Second recruit, login MySQL

The syntax is as follows: Mysql-u user name-p user Password

Type the command mysql-uroot-p,

Enter the password when prompted, enter 12345, and then enter into MySQL, MySQL prompt is:

Mysql> Note that if you are connected to another machine, you need to add a parameter-H machine IP

Third recruit, add new user

Format: Grant permission on database. * To User name @ login host identified by "password"

For example, add a user user1 password to Password1, so that it can log on on the computer, and for all the number

According to the library has the right to query, insert, modify, delete. First connect the root user to MySQL, and then type the following command:

Grant Select,insert,update,delete on *.* to User1@localhost

Identified by "Password1";

If you want the user to be able to log on to MySQL on any machine, change the localhost to "%".

If you do not want to User1 have a password, you can make another command to remove the password.

Grant Select,insert,update,delete on mydb.* to User1@localhost

Identified by "";

MySQL remote login and Common commands

Four strokes, Operation database

Log in to MySQL, and then run the following commands under the MySQL prompt, with each command ending with a semicolon.

1. Display the list of databases.

show databases;

There are two databases by default: MySQL and test.

MySQL inventory with MySQL system and user rights information, we change the password and new users, is actually the library to operate.

2, display the data table in the library:

Use MySQL;

Show tables;

3, display the structure of the data table:

describe table name;

4, the establishment and deletion of the library: Create database library name;

drop Database library name;

5, Build table: use library name;

CREATE TABLE table name (field list);

The drop table table name;

6, clear the table record:

Delete from table name;

7, display the records in the table:

SELECT * from table name;

MySQL remote login and Common commands

V. Recruit, export, and import data

1. Export data: mysqldump--opt Test > Mysql.test

Export the database test database to the Mysql.test file, which is a text file

such as: Mysqldump-u root-p123456--databases dbname >

Mysql.dbname

is to export the database dbname to the file mysql.dbname.

2. Import data: Mysqlimport-u root-p123456 < Mysql.dbname.

You don't have to explain.

3. Import text data into the database:

The field data for the text data is separated by the TAB key.

Use test; Load data local infile "filename" into table name;

1: Use the show statement to find out what database is currently on the server:

Mysql> show DATABASES;

2: Create a database Mysqldata

mysql> CREATE DATABASE Mysqldata;

3: Select the database you created

mysql> use Mysqldata; (press ENTER to appear database changed

The operation is successful!) 4: See what tables exist in the current database

Mysql> show TABLES;

5: Create a database table

Mysql> CREATE TABLE MYTABLE (name VARCHAR), sex

CHAR (1)); 6: Show the structure of the table:

Mysql> DESCRIBE MYTABLE;

7: Add records to the table mysql> insert into MYTABLE values ("HyQ", "M");

8: Load data into a database table (for example, d:/mysql.txt) in text mode

mysql> LOAD DATA Local INFILE "D:/mysql.txt" into

TABLE MYTABLE;

9: Import. sql file command (e.g. D:/mysql.sql)

Mysql>use database;

Mysql>source D:/mysql.sql;

10: Delete table Mysql>drop tables MYTABLE;

11: Clear the table mysql>delete from MYTABLE;

12: Update the data in the table Mysql>update MYTABLE set sex= "F" where

Name= ' HyQ ';

Posted on 2006-01-10 16:21 Happytian

13: Back Up the database

Mysqldump-u Root Library name >xxx.data

14: For example, connect to MySQL on a remote host

Assume the IP of the remote host is: 110.110.110.110, username is root, password is abcd123. Type the following command:

mysql-h110.110.110.110-uroot-pabcd123//MySQL remote Login

(Note: U and root can be without spaces, others are the same)

Exit MySQL command: Exit (enter)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.