樹心幽徑

« 20181030在ubuntu用c在mysql ilvssell資料庫建立new_outcome_detail資料表並加入一筆資料(t13.c) | Main | 20181104修改new_cust資料表中某一客戶(custno)的儲值金額(remain) t14.c »

20181101在伺服端建立mysql連線用戶並在用戶端用C程式碼連線
2018/11/01,09:23

(一)伺服端(insecta.idv.tw)

mysql>  GRANT ALL ON ilvssell.* to treehrt@tree.kmvs.km.edu.tw;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON  *.* to 'treehrt'@'%' IDENTIFIED by "?" WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> use mysql;
Database changed
mysql> UPDATE user SET Password=PASSWORD('?') where USER='treehrt';
Query OK, 1 row affected (0.00 sec)
Rows matched: 4  Changed: 1  Warnings: 0

mysql>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

 

(二)用戶端程式碼(tree.kmvs.km.edu.tw)

if (mysql_real_connect(con, "insecta.idv.tw", "treehrt", "?",
          NULL, 0, NULL, 0) == NULL)
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  } 

迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType