HOMEBREW Detailed

Homebrew is a package manager for Mac, similar to yum or apt-get in Linux system, it can make your Mac more perfect. mongodb is a NOSQL database, a document database, which is different from traditional relational databases (mysql, orcal, etc.). This article gives a basic introduction to brew and installs mongoddb on Mac using brew and its problems and precautions ( Note from the author)

There are more tasks that need to be completed in recent work , So the previous series of blogs (a series of articles based on gulp requirejs rjs’s front-end automation construction) have not been completed. First insert a blog here to record some things. Because we need to build a framework for our existing front-end framework in our work recently. A backend system with output is used to complete front-end construction and output projects. So I am going to use node + express for project evaluation and mongodb for persistence. This article records the use of brew to install mongodb under Mac.

Homebrew

Homebrew is a software package management tool for Mac, we can use it to install and uninstall software on our Mac Software etc. If you use Homebrew, we must first install Homebrew under our Mac, execute the following command to install:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/ install/master< /span>/install)" 

Homebrew The installation is very simple, use a ruby ​​command, our Mac computer comes with ruby, you can try it in the terminal:

ruby -v

As follows, output ruby ​​version:

View ruby ​​version under Mac terminal< /p >

Execute the installation command, install brew, after the installation is complete, we will You can use brew to install the software on the Mac. Before installing mongodb, let’s learn about brew. First, how to uninstall brew? If you don’t know how to uninstall, you can execute the brew installation command again, if you have already installed it. If brew executes the installation command again, it will give you a prompt telling you that brew has been installed on your system. If you want to repeat the installation, execute the uninstall command. In this way, you can execute the following uninstall command according to the terminal prompt. I also posted the uninstall command of brew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" 

In fact, it is ok to change the install command in the installation command to uninstall NS.

Here are some common brew commands:< /p>

1. Follow the new brew itself

< pre>brew update

2. Use brew to install the software

brew install soft_name
// soft_name is the sign of the software you want to install, such as using brew to install git
brew install git

3. Use brew to uninstall the software

brew uninstall soft_name
// soft_name is the sign of the software you want to uninstall, such as using brew to uninstall git
brew uninstal l git

4, display use List of software installed by brew

brew list

5. Update software

brew upgrade // Update all software installed with brew
brew upgrade git // Update a software installed with brew

6. Check which software needs to be updated

brew  outdated

7. Find software< /p>

// When you can’t remember the name of the software, you can use search, just write a few words A letter, he will help you associate and output all possible results to you 
brew search

The following figure shows the output result of using brew search gi:

Use brew search gi

8. Check what is installed with brew and where it is installed

brew --cache

More commands

Use brew to install mongodb

1. With brew, we can install mongodb very easily:

brew install mongodb

installation complete

< p style="line-height:28px;font-size:18px;color:rgb(182,138,0);font-family:Georgia, Helvetica;">2. Afterwards, upgrade our mongodb to ensure the latest version< /p>

brew upgrade mongodb

If you start mongo now, you will not succeed, as follows:

Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused

Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146

exception: connect failed

3. Before starting mongo, we need to create a directory, which is the default for mongo Write the data into the directory

mkdir -p /data/db 

4. Then give the newly created directory a readable Permission to write

chown `id -u` /data/db

5. Modify the directory

// /data/db The directory is the default directory of mongo. If you want to use another directory, you can use the --dbpath parameter
mongo --dbpath dir_name
// dir_name is your directory name

Now, you can start mongodb with confidence, execute The following command:

mongod

If the above error is still included, maybe you can try the following command:

brew services start mongodb

However, brew services will be abolished and no one has maintained them. Click here for details.

Now if everything goes well, it should look like this:

mongodb started successfully

If one day you find that your database suddenly fails to start, it may be caused by a normal shutdown. You can delete mongod. lock the file, then restart, if it still doesn’t work, you can check the process, then Kill:

ps -aef | grep mongo

< p style="line-height:28px;font-size:18px;color:rgb(182,138,0);font-family:Georgia, Helvetica;">as follows:

Process

Then kill the process according to the process ID:

sudo kill< /span> 6955

Restart the mongodb service, ie Yes:

mongod

We can open a new terminal window to connect to the database and try to view all the databases:

mongo

show dbs

View database

Finally, like everyone recommend a client-side visualization tool robomongodb that connects to mongo. It is a cross-platform tool. We can download the Mac version and open it after installation. The interface looks like this:

robomongodb interface

click the create button to create a new connection, a connection configuration box will pop up, there are some default parameters, we keep the default, directly click save, and then Just click the connect button:

click create to create a connection

The following figure is the interface after clicking connect to connect to the database successfully

Click connect to connect to the database

Well, other authors will continue to play tricks, everyone encourages, and study hard.

Homebrew is a package manager for Mac, similar to yum or apt-get in Linux system, it can make your Mac more perfect. mongodb is a NOSQL database, a document database, which is different from traditional relational databases (mysql, orcal, etc.). This article gives a basic introduction to brew and installs mongoddb on Mac using brew and its problems and precautions ( Note from the author)

There are more tasks that need to be completed in recent work , So the previous series of blogs (a series of articles based on gulp requirejs rjs's front-end automation construction) have not been completed. First insert a blog here to record some things. Because we need to build a framework for our existing front-end framework in our work recently. A backend system with output is used to complete front-end construction and output projects. So I am going to use node + express for project evaluation and mongodb for persistence. This article records the use of brew to install mongodb under Mac.

Homebrew

Homebrew is a software package management tool for Mac, we can use it to install and uninstall software on our Mac Software etc. If you use Homebrew, we must first install Homebrew under our Mac, execute the following command to install:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/ install/master< /span>/install)" 

Homebrew The installation is very simple, use a ruby ​​command, our Mac computer comes with ruby, you can try it in the terminal:

ruby -v

As follows, output ruby ​​version:

View ruby ​​version under Mac terminal< /p>

Execute the installation command, install brew, after the installation is complete, we can use brew Install the software under Mac. Before installing mongodb, let’s learn about brew. How to uninstall brew first? If you don’t know how to uninstall, you can execute the brew installation command again, if you have already installed brew, execute it again If you install the command, it will give you a prompt telling you that brew has been installed on your system. If you want to repeat the installation, execute the uninstall command. In this way, you can execute the following uninstall command according to the prompt of the terminal. In addition, I also put The uninstall command of brew is posted:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" 

In fact, it is ok to change install in the installation command to uninstall.

Here are some common brew commands:< /p>

1. Follow the new brew itself

< pre>brew update

2. Use brew to install the software

brew install soft_name
// soft_name is the sign of the software you want to install, such as using brew to install git
brew install git

3. Use brew to uninstall the software

brew uninstall soft_name
// soft_name is the sign of the software you want to uninstall. For example, use brew to uninstall git
brew uninstall git

4. Show the software installed with brew List

brew list

5. Update software

brew upgrade // Update all software installed with brew
brew upgrade git // Update a software installed with brew

6. Check which software needs to be updated

brew outdated

7. Find software

< pre>// When you can’t remember the name of the software, you can use search, just write a few letters, he Will help you think about it and output all possible results to you
br ew search

The picture below shows the use of brew search gi Output result:

Use brew search gi

8. Check what is installed with brew and where it is installed

brew --cache

More commands

Use brew to install mongodb

1. With brew, it becomes very simple for us to install mongodb:

brew insta ll mongodb

installation complete

2. Afterwards, upgrade our mongodb to ensure the latest version

brew upgrade mongodb

If you start mongo now, you will not succeed, as follows:

Failed to connect to 127.0.0.1:27017, reason : errno:61 Connection refused

Error: couldn't connect to server 127.0.0.1:27017 (127.0 .0.1), connection attempt failed at src/mongo/shell/mongo.js:146

exception: connect failed

3. Before starting mongo, we need to create a directory to write the default data into the directory for mongo

< pre>mkdir -p /data/db

4, then give the newly created directory read and write permissions

 chown ` id -u` /data/db

5. Modify the directory

// /data/db directory is the default directory of mongo, if you want To use other directories, you can use the --dbpath parameter
mongo --dbpath dir_name
// dir_name is your directory name

Now, you can start mongodb with confidence, execute the following command:

mongod

If the above error is still included, maybe you can try the following command:

brew services start mongodb

However, brew services are about to be abolished and no one maintains them. Click here for details.

Now if all goes well, it should look like this:

start mongodb successfully

If one day you find that your database suddenly fails to start, it may be caused by your normal shutdown. You can delete the mongod.lock file and restart it. If it still doesn’t work, you can check the process. Then kill:

ps -aef | grep mongo

as follows:

process

Then kill the process according to the process ID:

sudo kill 6955

restart the mongodb service, you can:

mongod

We can open a new terminal window to connect to the database and try to view all the databases:

mongo
show dbs

< img src="/wp-content/uploads/images/os/macos/1626797495207.jpg" alt="view database" style="border:none;vertical-align:top;" >

Finally, like everyone recommends robomongodb, a client visualization tool that connects to mongo. Platform tools, we can download the Mac version, open after installation, the interface looks like this:

robomongodb interface

Click the create button to create a new one Connect, a connection configuration box will pop up, there are some default parameters, we keep the default, just click save, and then click the connect button:

click create Create connection

The following figure is the interface after clicking connect to connect to the database successfully

Click connect to connect to the database

Alright, other authors will continue Play tricks, everyone encourages, study hard, Sao Nian.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5167 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.