• 首页|
  • Community
    Articles Topics Q&A
    Learn
    Course Programming Dictionary
    Tools Library
    Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins
    AI Tools
    Leisure
    Game Download Game Tutorials
    search
    English
    简体中文 English 繁体中文 日本語 한국어 Melayu Français Deutsch
    Login
    singup
    Home Database Mysql Tutorial MySQL杂记(更新时间2014.05.23)_MySQL

    MySQL杂记(更新时间2014.05.23)_MySQL

    WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
    WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
    Jun 01, 2016 pm 01:10 PM

    1. -- 导出远程数据
      mysqldump.exe

      --defaults-extra-file="c:/docume~1/admini~1/locals~1/temp/tmpx9h0e7.cnf"
      --set-gtid-purged=OFF --user=tongzhou --max_allowed_packet=1G
      --host=192.168.1.102 --port=3306 --default-character-set=utf8 "datacenterb" "cib_cs_130805_s2014"
      (该操作是从mysqlwokbench 工具中远程导出表的时候生成的语句,但是还没有测试过)

    2. 数据库试用规约

      1. 以下的注意事项主要是为了:提高查询速递、减少数据库的压力

       

      i.  所有和数据库的链接(connection)必须是打开、使用、关闭;

      ii.  给经常使用的某一列建立索引和约束(索引是因为实际生产的需要)(约束该项有待商榷);

      iii.  写入数据库(insert into table)的时候尽量用批量提交的方式(批量提交分java程序控制——java的批量提交方式,以及程序员手动控制——自己组合insert 语句两种);

      iv.  在实际的查询中如果select需要查询所有的列,则用select* 否则尽量使用select+ column 的查询方式;

      v.  子查询的使用:不要超过二级子查询,因为数据量大的原因,二级子查询可能导致数据库的超时;

      vi.  视图的使用:尽量不要建立二级视图(视图上建立视图),因为二级视图会严重影响查询的效率;

      vii.  字段长度:不要太长,但也要给字段留有余地;

    3. 导入导出数据

      1. 本地导入mysql数据

         mysql  source D:/123.sql;

      2. 本地导出mysql数据
        mysqldump -u root -p test >D:/456.sql 导出数据

    4. 修改密码root
      mysqladmin -u 用户名 password 新密码 –p  
          mysqladmin -u root -p password mypasswd
      执行后提示输入旧密码,确认后即修改成功

    5. mysql授权语句(database 是数据库的名称,username是用户名密码 root 是用户名)
          grant all privileges on datacenterb.* to root@'%' identified by 'username';
      刷新权限(一定记得,有些时候他不刷新的话不能很快的反应过来)
          flush privileges;

    6. 批量删除数据库中的表   (没有比这个更简单的语句了,目的是组合删除语句,而后自己执行该删除句子)

      1. select CONCAT( 'drop table ', table_name, ';' ) from information_schema.tables where table_schema='database1' and table_name like'%cache';

    7. mysql批量导入导出

      1. 导出

        1. mysqldump -uROOT -pROOT -hlocalhost DB2014 2012_05051_s201401 > D:/outfile/1.sqlmysqldump -uROOT -pROOT -hlocalhost DB2014 2012_05051_s201402 > D:/outfile/2.sqlmysqldump -uROOT -pROOT -hlocalhost DB2014 2012_05051_s201403 > D:/outfile/3.sq
          Copy after login
      2. 导入

        1. mysql -uROOT -pROOT -hlocalhost DBtest < D:/outfile/1.sqlmysql -uROOT -pROOT -hlocalhost DBtest < D:/outfile/2.sqlmysql -uROOT -pROOT -hlocalhost DBtest < D:/outfile/3.sql
          Copy after login

          PS:这个导出的文件名称以可以随便指定,但是文件的后缀名称必须是sql

    8. Windows netstat 查看端口、进程占用

      1. 目标:在Windows环境下,用netstat命令查看某个端口号是否占用,为哪个进程所占用操作:操作分为两步:

        1. (1)查看该端口被那个PID所占用;

          1. 方法一:有针对性的查看端口,使用命令Netstat –ano|findstr “”,如图,最后一列为PID。图中的端口号为1068,所对应的PID为3840。                                       eg ——〉Netstat –ano|findstr "65340"

          2. 方法二:查看所有的,然后找到对应的端口和PID。eg ——〉netstat -ano

        2. (2)查看该PID对应的进程名称。

          1. 方法一:一直用命令查找,tasklist|findstr “”

          2. 方法二:用任务管理器查看。

      2. 附录:在命令行中输入netstat /? 可以查看netstat的相关信息。

    9. ###

       

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Show More

    Hot Article

    How to fix KB5055523 fails to install in Windows 11?
    4 weeks ago By DDD
    How to fix KB5055518 fails to install in Windows 10?
    4 weeks ago By DDD
    Roblox: Grow A Garden - Complete Mutation Guide
    3 weeks ago By DDD
    Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    How to fix KB5055612 fails to install in Windows 10?
    3 weeks ago By DDD
    Show More

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Show More

    Hot Topics

    Java Tutorial
    1664
    14
    CakePHP Tutorial
    1423
    52
    Laravel Tutorial
    1317
    25
    PHP Tutorial
    1268
    29
    C# Tutorial
    1243
    24
    Show More
    Related knowledge
    When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

    Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

    MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

    MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

    MySQL: The Ease of Data Management for Beginners MySQL: The Ease of Data Management for Beginners Apr 09, 2025 am 12:07 AM

    MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

    MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

    The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

    Explain the role of InnoDB redo logs and undo logs. Explain the role of InnoDB redo logs and undo logs. Apr 15, 2025 am 12:16 AM

    InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

    MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

    MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

    MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

    MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

    Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

    MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

    See all articles

    Public welfare online PHP training,Help PHP learners grow quickly!

    About us Disclaimer Sitemap

    © php.cn All rights reserved