您的位置:首页 > 数据库 > Redis

ubuntu 下安装 mysql + redis + mongodb

2017-04-19 00:00 561 查看

安装mysql

== mysql 安装的事5.7 版本 使用 insert 提示密码不存在 ==

1 更新源

root@192-168-0-7:~# apt-get update

2.安装mysql-server

root@192-168-0-7:~# apt-get install mysql-server
# 下面的步骤会出现设置密码界面
--输入密码
--确认密码

# 修改mysql密码(mysql-server需启动状态)
root@192-168-0-7:~# mysql -uroot -p                                #进入mysql

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('ccloud')    # 修改mysql密码

3.查看下mysql的服务

root@192-168-0-7:~# netstat -tap | grep mysql
tcp        0      0 localhost.example:mysql *:*                     LISTEN      6174/mysqld

4.为mysql创建外网访问账户

root@192-168-0-7:~# mysql -u root -p
Enter password:
==Welcome== to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.17-0ubuntu0.16.04.2 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create user "ccloud"@"%" identified by 'ccloud';
Query OK, 0 rows affected (0.00 sec)

PS:username - 你将创建的用户名,

host - 指定该用户在哪个主机上可以登陆,此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录,如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录;也可以指定某台机器可以远程登录;

password - 该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器。

5.授权账户

root@192-168-0-7:~# mysql -u root -p  下执行 授权用户
mysql> grant all on mysql.* to ccloud

6.配置远程访问

-- 在创建ccloud的时候已经制定的所有ip都能访问

mysql>create user "ccloud"@"%" identified by 'ccloud';    #(%) 指定所有ip都能访问

-- 修改配置文件

root@192-168-0-7:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf
将
bind-address            = 127.0.0.1
修改为
bind-address            = 0.0.0.0

-- 重启服务

root@192-168-0-7:~# service mysql restart

-- 进入mysql设置远程访问用户的权限(远程出现(mysql Access denied for user root@localhost) 就是由此产生)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'ccloud'@'%' IDENTIFIED BY 'ccloud' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

-- 刷新权限

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

安装redis

1.安装redis

root@192-168-0-7:~# apt-get install redis

2.查看redis是否启动和redis的服务

root@192-168-0-7:~#  ps -aux|grep redis
redis      7272  0.0  0.0  40136  6724 ?        Ssl  17:14   0:00 /usr/bin/redis-server 127.0.0.1:6379
root       7334  0.0  0.0  14224  1008 pts/2    S+   17:16   0:00 grep --color=auto redis

root@192-168-0-7:~# netstat -tap | grep redis
tcp        0      0 localhost.example:6379  *:*                     LISTEN      7272/redis-server 1

安装mongodb 数据库

1.安装mongodb

root@192-168-0-7:~# apt-get install mongodb

2.启用mongodb

root@192-168-0-7:~# service mongodb start

3.查看mongodb 的服务

root@192-168-0-7:~# netstat -tap |grep mongod
tcp        0      0 localhost.example:27017 *:*                     LISTEN      7858/mongod
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql5.7 redis MongoDB