2020年1月20日 星期一

InfluxDB External Access and Create User

https://www.itread01.com/content/1550450725.html

InfluxDB Create User

influx
create user admin with password 'admin'
grant all privileges to admin

set password for admin = 'admin'
drop user admin
revoke all on mydb from admin
show grants for admin

External Access

Edit C:\temp\influxdb-1.7.9-1\influxdb.conf so that
auth-enabled = true


NSSM

nssm install
C:\temp\influxdb-1.7.9-1\influxd.exe
C:\temp\influxdb-1.7.9-1\
-config "C:\temp\influxdb-1.7.9-1\influxdb.conf"
InfluxDB


CLI

influx -username admin -password admin

or

influx
auth
admin
admin

End


2020年1月17日 星期五

Visual Studio C++ std::string std::wstring utf8 UTF-8


Using (MT5)

// convert UTF-8 string to wstring
std::wstring utf8_to_wstring (const std::string& str)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
    return myconv.from_bytes(str);
}

// convert wstring to UTF-8 string
std::string wstring_to_utf8 (const std::wstring& str)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
    return myconv.to_bytes(str);
}

CHAR 936 to UTF8 (MT4)
https://blog.csdn.net/WU9797/article/details/96124105

std::string GBToUTF8Ex(const char *input) {
if (!input || strlen(input) < 1)
return "";
std::stringstream ss;
int len = MultiByteToWideChar(936, 0, input, -1, NULL, 0);
wchar_t *wstr = new wchar_t[len + 1];
memset(wstr, 0, len + 1);
MultiByteToWideChar(936, 0, input, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char *str = new char[len + 1];
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
ss << str;
delete[]wstr;
delete[]str;
return ss.str();
}


Someone's method does not work for me
inline std::string charsetToUtf8String(const std::string & string) {
int wchars_num = MultiByteToWideChar(936, 0, string.c_str(), -1, NULL, 0);
std::wstring wResult(wchars_num, ' ');
// charset 936 = Chinese Simplified (GB2312)
MultiByteToWideChar(936, 0, string.c_str(), -1, &wResult[0], wchars_num);
return toString(wResult);
}

inline std::string toString(const std::wstring & wstring) {
return utility::conversions::utf16_to_utf8(wstring);
}

2020年1月8日 星期三

Change or move MongoDB 4.0 data folder on Windows 10

In 2019, a typical MongoDB 4.0 installs with data folder at C:\Program Files\MongoDB\Server\4.0\data with a service.

How to move \data to another bigger drive, say D drive?

1. services.msc, stop MongoDB service
2. Move all files from C:\Program Files\MongoDB\Server\4.0\data to D:\Program Files\MongoDB\Server\4.0\data
3. Edit C:\Program Files\MongoDB\Server\4.0\bin\mongod.cfg so that its dbPath starts a D: instead of C:

storage:
  dbPath: D:\Program Files\MongoDB\Server\4.0\data
  journal:
    enabled: true

4. admin cmd.exe, run below

C:\Program Files\MongoDB\Server\4.0\bin>mongod --config "C:\Program Files\MongoD
B\Server\4.0\bin\mongod.cfg" --install

5. services.msc, start MongoDB service

Done!

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...