2017年12月20日 星期三

mysql setup

  • shell> mysql --user=root -p  an
  • 輸入密碼
  • mysql> use mysql  
  • mysql> GRANT SELECT,INSERT,UPDATE,DELETE ON [db_name].* TO [username]@[remoteIP] identified by '[password]';   
  • mysql> FLUSH PRIVILEGES;
其中幾項參數名稱的說明如下:
  • db_name:想要從遠端連接的資料庫名稱
  • username:就是 username 嘛,若你是遇上這個問題,這個通常就是 root 囉!
  • remoteIP:用戶或程式所在的遠端 IP,這邊可以使用 % 來開放某個網段,如:'192.168.%.%',注意兩個單引號是一定要加的喔!
  • password:就密碼啦,最好也加上兩邊的單引號。
  • 最後的最後記得加上 ; 因為這是SQL語法。
https://www.psce.com/blog/2012/04/01/how-to-find-mysql-configuration-file/


2017年12月11日 星期一

dd

 Public Shared Function getattachment(ByVal no As String) As Integer
        Dim conString As String = "Server=192.168.0.208;Port=5432; Userid=confluence_user;Password=confluence_user; Protocol=3;SSL=false;Pooling=true;Mi" &
      "nPoolSize=1; MaxPoolSize=20;Encoding=UNICODE; Timeout=15;SslMode=Disable;Database=confluence2"
        Dim ourDataTable1 As DataTable = Nothing
        Dim connection As Npgsql.NpgsqlConnection = New Npgsql.NpgsqlConnection(conString)
        Try
            'MsgBox(no)
            ourDataTable1 = New DataTable
            Dim ourAdapter1 As Npgsql.NpgsqlDataAdapter = New NpgsqlDataAdapter("select sdata1-sdata2 as rlt " &
    "from " &
    "( " &
        "select id3, sum(data1) as sdata1, sum(data2) as sdata2 " &
        "from " &
        " ( " &
            "select b.spacekey as id3,count(1) as data1, 0 as data2 " &
            "from content a,spaces b " &
            "where a.spaceid = b.spaceid  " &
               " and a.contenttype = 'PAGE' " &
                "and a.content_status = 'current' " &
                "and a.prevver is null and b.spacekey='" & no & "'" &
            " group by b.spacekey " &
            "union all " &
            "select id3, 0 as data1, id6 as data2 " &
            "from log2 where id2='7' and id3='" & no & "'" &
        ") v1 " &
       " group by id3 " &
    ") v2 ", connection)


            'CAST (id3 AS INTEGER)
            ' MsgBox("SELECT (t2.data - t1.data) AS data FROM log2 AS t1 INNER JOIN content AS t2 ON t1.id = t2.id WHERE t1.CAST (id3 AS INTEGER) =" & no & "")
            ourAdapter1.SelectCommand.Parameters.AddWithValue("@no", no)
            ' ourAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
            ourAdapter1.Fill(ourDataTable1)
            If IsDBNull(no) Then
                Return ""
            Else
                If ourDataTable1.Rows.Count <> 0 Then
                    Return ourDataTable1.Rows(0)("rlt").ToString
                Else
                    Return ""
                End If
            End If

        Catch ex As Exception

        End Try


    End Function

2017年12月6日 星期三