1024programmer Java mysql, redis, mongodb database installation

mysql, redis, mongodb database installation

Install mysql

If there is an installation dependency error, you can first update the download source with sudo apt-get update

1. Install the server

sudo apt-get install mysql-server

Start service

sudo service mysql start

Stop the service

sudo service mysql stop

Restart the service

sudo service mysql restart

Check whether mysql exists in the process

ps ajx|grep mysql

2 . MySQL configuration file

  • The configuration file directory is /etc/mysql/mysql.cnf

  • Enter the conf.d directory ,open mysql.cnf,found that there is no configuration
  • Enter the mysql.conf.d directory,Open mysql.cnf,You can see the configuration items

  • The main configuration items are as follows

bind- address represents the IP bound to the server,The default is 127.0.0.1port represents the port,The default is 3306 datadir represents the database directory,The default is /var/lib/mysqlgeneral_log_file represents the normal log,The default is / var/log/mysql/mysql.loglog_error represents the error log,The default is /var/log/mysql/error.log

3. Client installation

sudo apt-get install mysql-client

Connect to database

mysql -u username -p password

  • Press ctrl+d or enter the following command to exit

quit or exit

Install redis

1. Download the installation package

wget http://download.redis.io /releases/redis-4.0.9.tar.gz

2. Unzip the package

tar xzf redis-4.0.9.tar.gz

3. Move,to the usr/local directory

sudo mv ./redis-4.0.9 /usr/local/redis/

4. Enter the redis directory

cd /usr/local/redis/

5. Generate

sudo make

6. Test, this running time will be longer

sudo make test

7. Installation, install the redis command to the /usr/local/bin/ directory

sudo make install

8. After the installation is complete,We enter the directory /usr/local/bin to view

cd /usr/local/bin
ls -all

9. Move the configuration file to the /etc/ directory

  • The configuration file directory is /usr/local/redis/redis.conf

  • sudo cp /usr/local/redis/redis.conf /etc/redis/

  • Install Redis on Mac:

    • Install Homebrew:
    • https://brew.sh/
    • Use brew to install Redis
    • https://www.cnblogs.com /cloudshadow/p/mac_brew_install_redis.html

mongodb installation

1 Command installation

sudo apt-get install -y mongodbhttps://docs.mongodb.com/manual/tutorial/install-mongodb-on- ubuntu/

4.2 Source code installation

Unzip

tar -zxvf mongodb-linux-x86_64 -ubuntu1604-3.4.0.tgz

Move,to the usr/local directory

sudo mv -r mongodb-linux-x86_64 -ubuntu1604-3.4.0 /usr/local/mongodb/

p>

Add executable files to PATH

export PATH=/usr/local/mongodb/bin:$PATH

Startup of mongodb

1 Startup of server mongodb

Startup method 1:

  • Startup: sudo service mongod start
  • Stop: sudo service mongod stop
  • Restart: sudo service mongod restart
  • Location of configuration file :/etc/mongod.conf
  • Log Location:/var/log/mongodb/mongod.log
  • Default port:27017

Startup method 2:

  • Start: sudo mongod [--dbpath=dbpath --logpath=logpath --append -fork] [–f logfile ]
  • When only started with the sudo mongod command, the data is stored in the /data/db directory by default and needs to be created manually
  • --dbpath : Specify the storage path of the database
  • --logpath: Specify the storage path of the log
  • --logappend : Set the log writing mode to append mode
  • -fork: Start a new process to run the mongodb service
  • f: Configuration file (the above configuration information can be written to the file and then loaded and started through this parameter)

2 Client mongo

  • Start the local client: mongo
  • View help:mongo –help
  • Exit:exit or ctrl+c

3 mongodb official Documentation

Location:https://docs.mongodb.com/manual/introduction/

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/mysql-redis-mongodb-database-installation/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索