Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use MySQL skills to quickly understand MongoDB

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to use MySQL skills to quickly understand MongoDB". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

This article will help you learn to MongoDB based on your existing knowledge of MySQL and will lead you to a quick understanding of MongoDB.

I. installation

First, let's take a look at the installation steps for MySQL and MongoDB, both of which are very simple.

1. Windows installation of MySQL

The MySQL server installation package can be downloaded from the following website: http://dev.mysql.com/downloads/, the installation method depends on the downloaded installer, and there are two main installation methods:

(1), MSI Installer installation

Download the msi installer on the official website, double-click mysql-5.*.*-win32.msi, and follow the prompts step by step after the installation interface appears:

This installation method is easy to understand and conforms to the software installation habits of beginners. Next, let's take a look at the installation-free installation method.

(2), ZIP installation

If it is an advanced user, I would like to install it in this way, because the user can customize more options and make it easier to manage and maintain.

Step1: download the zip installer on the official website

Step2: extract the file to a directory of your choice, such as "D:MySQL"

Step3: under the "D:MySQL" directory, create a new my.ini file and add the following data to it:

[mysqld]

Basedir=D:MySQL

Datadir=D:MySQLdata

This method is more flexible for a professional DBA.

2. Windows installation of MongoDB

MongoDB can only be installed in zip mode on Windows platform, and the installation and configuration are much simpler than MySQL, as shown below:

Step1: download the ZIP installation package on the official website, pay attention to whether it is a 64-bit or 32-bit version, please choose the correct version.

Step2: extract the downloaded installation package on the "D:" disk and rename it to "mongodb"

Step3: create a "d:datadb" directory to store data files

Step4: execute the "d:mongodbbinmongod.exe" file to start the MongoDB server

Step5: open the browser and enter URL "http://localhost:27017/". If the following page appears, it starts normally:

You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number

3. Linux installation of MySQL

There are three common ways to install MySQL on the Linux platform, which are described below.

(1), RPM installation

Step1: download mysql server and client rpm installation files from the official website

Step2: performing rpm installation

Rpm-ivh MySQL-server-community-5.1.45-1.rhel5.i386.rpm

Rpm-ivh MySQL-client-community-5.1.45-1.rhel5.i386.rpm

This completes the rpm installation of mysql.

(2), binary installation

Step1: new MySQL users and user groups

Groupadd mysql

Useradd-g mysql mysql

Step2: decompress the downloaded mysql package

Tar zxvf mysql-5.1.45.tar.gz

Step3: move mysql-5.1.45 to / usr/local/mysql

Step4: initialize installation of mysql database

Cd / usr/local/mysql

Scripts/mysql_install_db-user=mysql

This completes the binary installation of mysql.

(3) installation by source code

Source code installation provides a way for advanced users to customize the installation. Users can configure more options and use MySQL more flexibly.

Step1: new MySQL users and user groups

Groupadd mysql

Useradd-g mysql mysql

Step2: decompress the downloaded mysql package

Tar zxvf mysql-5.1.45.tar.gz

Cd mysql-5.1.45

Step3: use the configure tool to compile the source code. Here we can use many parameters, which can be viewed with configure-- help. Here we install MySQL under / usr/local/MySQL.

. / configuer-- prefix=/usr/local/MySQL

Make

Make install

Step4: select a configuration file and copy it to / etc/ and rename it to my.cnf

Cp support-files/my-medium.cnf / etc/my.cnf

Step5: initialize installation of mysql database

Cd / usr/local/mysql

Bin/mysql_install_db-user=mysql

Step6: modify directory permissions

Chown-R root.

Chown-R MySQL var

Chgrp-R MySQL.

Step7: enable MySQL service

. / bin/mysqld_safe-- user=mysql

This completes the source installation of mysql.

4. Linux installation of MongoDB

The installation procedure on MongoDB's Linux platform is the same as that of Windows, except that the operating system is different.

Step1: download the tgz installation package on the official website, pay attention to whether it is a 64-bit or 32-bit version, please choose the correct version.

Step2: unpack the downloaded installation package on the "/ Apps/" disk and rename it "mongodb"

Step3: create a "/ data/db" directory to store data files

Step4: execute the "/ Apps/mongodb/bin/mongod" file to start the MongoDB server

Step5: open the browser and enter URL "http://192.168.1.103:28017/". If a page asks you to enter your user name and password, it will start normally.

To sum up, for MongoDB, a newcomer in the field of NoSQL, its installation is simpler and more convenient than MySQL.

2. Data storage structure

1. The data storage structure of MySQL

Each database of MySQL is stored in a folder with the same name as the database. The MySQL database files include the database files built by MySQL and the database files created by the storage engine used by MySQL.

If MySQL uses the MyISAM storage engine, the database file types include .frm, .MYD, .MYI

If MySQL uses the InnoDB storage engine, the database file types include .frm, ibdata1, .ibd

(1). Database files:

.frm file: the framework structure for storing data tables. The MySQL database file name is the same as the table name, and each table corresponds to a frm file with the same name, which has nothing to do with the operating system and storage engine, that is, no matter what operating system MySQL runs on and what storage engine it uses. In addition to the required .frm files, the storage engine creates different database files depending on the storage engine used by MySQL (the two commonly used storage engines in MySQL are MyISAM and InnoDB).

This is the end of "how to use MySQL skills to quickly understand MongoDB". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report