MySQL Connection database

Source: Internet
Author: User

Wow, there's something in the background today! Does "MySQL" Count? Hehe, anyway feel write code write very happy, take today's summary of it! (Great God, do not like, do not spray)

1. Start MySQL first and link data for a few things! It's going to be, right?

MYSQL-UROOT-P//Connection data

net start MySQL//start MySQL

2, query the current server what data

show databases;

3. Create a database

Create DATABASE jddb-------databases name (JDDB)

4. Using the database
Use JDDB;

5. Query what tables are in the current database

Show tables;

6. Insert a table to the database

key,userName varchar (null,pwd varchar (null,null, sex varchar (null);

7. Inserting data into the table

Insert into User (Username,pwd,age,sex) VALUES (' Xiaoa ', ' abc123 ', 21, ' Male ');

Insert into User (Username,pwd,age,sex) VALUES (' xiaof ', ' CCCCC ', 48, ' female ');

Insert into User (Username,pwd,age,sex) VALUES (' Xiaog ', ' CCCCC ', 91, ' Male ');

8. Query data

select * from user;

Note: (This is likely to appear some small garbled event, then solve it!)

Solve garbled problem My.ini [mysqld] Write CHARACTER-SET-SERVER=GBK restart
Server

9, for the data just inserted in the table can be modified

Update user set age=20 where username= ' Xiaoa ';

10. Enquiry

Select Username,age,sex from user;

SELECT * from user where sex= ' man '

11. Delete

Delete from user where age>90 (this will remove the third data)

12. Modify Table name

ALTER TABLE user Rename to Huiyuan

13. Delete a table

--drop table user;
--drop database jddb;

14, a little follow-up work, you can back up the database it!

Database backup Data Export
Mysqldump-uroot-p >g:\jddb.sql

Database Restore Data Import
SOURCE G:\jddb.sql

Mysql-uroot-p Jddb<g:\jddb.sql

15. Close the database

NET stopt mysql//start MySQL

MySQL Connection database

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.