1. Postgresql

1.1 解压版安装

  • 1、创建 data 文件夹

image-20210501142424464.png

  • 2、初始化data目录
  1. initdb.exe -U postgres -W --locale=C -E UTF8 -D "E:\database\pgsql\data"
  2. 参数:
  3. -U, --username=NAME 数据库超级用户名
  4. -W, --pwprompt 对于新的超级用户提示输入口令
  5. --locale=C 为新数据库设置默认语言环境
  6. -E, --encoding=ENCODING 为新数据库设置默认编码
  7. -D, --pgdata=DATADIR 当前数据库簇的位置
  • 3、安装服务
  1. pg_ctl.exe register -D "E:\database\pgsql\data"
  2. # 可以通过-N 指定生成的服务名字,如
  3. # pg_ctl.exe register -N "pgsql" -D "D:\database\postgresql\pgsql\data"



2.MySQL

2.1解压版安装(8.0.~)

  • 1、创建一个名为 my.ini 的文件

    1. [mysql]
    2. # 设置mysql客户端默认字符集
    3. default-character-set=utf8
    4. [mysqld]
    5. # 设置3306端口
    6. port = 3306
    7. # 设置mysql的安装目录
    8. basedir = D:\\database\\mysql-8.0.21-winx64
    9. # 设置mysql数据库的数据的存放目录
    10. datadir =D:\\database\\mysql-8.0.21-winx64\\data
    11. # 允许最大连接数
    12. max_connections=20
    13. # 服务端使用的字符集默认为8比特编码的latin1字符集
    14. character-set-server=utf8
    15. # 创建新表时将使用的默认存储引擎
    16. default-storage-engine=INNODB
    17. # 创建模式
    18. sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  • 2、在bin目录执行 mysqld —initialize 命令,此时会生成一个新目录 data,查看 xxx .err 文件,可以看到 root 用户生成的随机密

image-20210502223354621.png

  • 3、执行 mysqld —install 命令,安装 mysql 服务
  • 4、执行 net start mysql 命令,启动 mysql 服务
  • 5、执行 mysql -u root -p 命令,连接 mysql 数据库,输入上述随机生成的密码;
  • 6、执行以下 SQL 重置 root 密码
  1. alter user 'root'@'localhost' identified with mysql_native_password by '新密码';

备注:

  • mysqld –initialize-insecure 自动生成无密码的 root 用户;
  • mysqld –initialize 自动生成带随机密码的 root 用户;
  • mysqld -remove 移除自己的 mysql 服务;
  • net stop mysq 命令,停止 mysql 服务
  • 如果报错,清空 data 文件夹,最好还是删掉 data 文件,重新执行 remove—initialize—install—start(这些不是命令)流程即可

2.2 MySQL忘记密码(8.0.~)

1.打开cmd窗口(管理员身份),停止mysql服务

  1. net stop mysql

2.开启跳过验证密码的mysql服务

  1. mysqld --console --skip-grant-tables --shared-memory

3.打开一个新的cmd窗口,启动mysql服务

  1. mysql -u root -p

4.输入密码—直接回车

5.将密码置空

  1. use mysql
  2. update user set authentication_string=‘’ where user=‘root’;
  3. exit

6.重新开启mysql服务,无密码登陆,修改密码

  1. ALTER USER root’@‘localhost IDENTIFIED WITH mysql_native_password BY 123456’;
  2. flush privileges

2.3 mysql 5.7



3.Redis

3.1 Windows安装

  • 安装服务
  1. redis-server.exe --service-install redis.windows.conf

卸载服务:redis-server —service-uninstall

开启服务:redis-server —service-start

停止服务:redis-server —service-stop

重命名服务:redis-server —service-name name,需要写在前三个参数之后,eg:

  1. redis-server --service-install --service-name redisService1 --port 10001
  2. redis-server --service-start --service-name redisService1



4. ElasticSearch

4.1 添加密码 7.11

  • 1、修改 elasticsearch.yml,加上以下配置项:
  1. xpack.security.enabled: true
  2. xpack.license.self_generated.type: basic
  3. xpack.security.transport.ssl.enabled: true
  • 2、设置密码,elasticsearch/bin 目录下,执行命令: ./elasticsearch-setup-passwords interactive
  1. # 修改指定账号的密码 --- 把 elastic 密码改成 123456
  2. curl -H "Content-Type:application/json" -XPOST -u elastic 'http://localshot:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
  3. ## 执行之后,输入一遍原始密码,即可以成功修改成新的密码
  • 3、修改Kibana配置 —— kibana.yml
  1. elasticsearch.username: "kibana_system"
  2. elasticsearch.password: "953598751"
  • 4、修改 logstash 配置
  1. ##### logstash.yml
  2. xpack.monitoring.enabled: true
  3. xpack.monitoring.elasticsearch.username: logstash_system
  4. xpack.monitoring.elasticsearch.password: 953598751
  5. xpack.monitoring.elasticsearch.hosts: ["http://ip:9200"]
  6. ##### xxxxx.conf
  7. elasticsearch {
  8. hosts => ["localhost:9200"]
  9. index => "xxxxx"
  10. document_id => "%{id}"
  11. user => "elastic"
  12. password => "953598751"
  13. }

4.2 添加密码 8.x

  1. ./bin/elasticsearch.bat
  2. ## 设置密码
  3. elasticsearch-reset-password --username elastic -i
  4. # Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
  5. xpack.security.http.ssl:
  6. ## 关闭 HTTP API客户端连接加密,
  7. enabled: false
  8. keystore.path: certs/http.p12
  9. ## 设置 kibana 链接密码
  10. elasticsearch-reset-password --username kibana_system -i
  11. ### kibana.yaml
  12. elasticsearch.username: "kibana_system"
  13. elasticsearch.password: "password"
  14. ## kibaba 中文
  15. i18n.locale: "zh-CN"