「開発」カテゴリーアーカイブ

MySQL・・・その2

LinuxMintにMySQL8を入れたが、他のPCから接続できるようにする。

Linux側の設定

・MySQLにユーザーを追加(TESTAdmin)

CREATE USER '[user]'@'%' IDENTIFIED BY '[password]'
GRANT SELECT, INSERT, DELETE, UPDATE ON [databese].* TO '[user]'@'%';

・mysqld.cnfの設定変更(bind-address = 0.0.0.0 mysqlx-bind-address=0.0.0.0)

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

・FWにMySQLのポートを設定(3306)

WIndows側の設定

・Dbeaverのインストール
・接続情報の登録(TESTAdmin・test)
・接続のパラメータを追加する(allowPublicKeyRetrieval=true,useSSL=false)

ユーザー認証の設定が平文パスワードなので、セキュリティ上は低い
MySQL8では、高度な認証を設定できるので、次回、試してみる。

ポートの変更もしたいね。

LinuxMintでMySQL

何回かインストールに失敗したのでメモする

インストールは・・・

sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation

ここで最初にrootのパスワードを入力する。
後はひたすら「Y」でエンター
★これを理解できず何度も繰り返した(削除とインストール)

動作確認

sudo systemctl status mysql

ログインする

sudo mysql -u root -p

 でエンター

<password> さっきのrootパスワード

$ sudo mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.40-0ubuntu0.24.04.1 (Ubuntu)

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

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>

ログインできた〜

ログアウトは
exit

自動起動設定

sudo systemctl start mysql
sudo systemctl enable mysql

さて、MySQLを全削除するには・・・

sudo systemctl stop mysql
sudo systemctl disable mysql
sudo apt-get remove --purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
sudo rm -rf /var/cache/mysql

これで完全に削除されるそうな・・・

SHOW DATABASES;


+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| sys |
+——————–+
4 rows in set (0.02 sec)

mysql>

DBを作成

CREATE DATABASE test;
SHOW DATABASES;


+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+——————–+
5 rows in set (0.00 sec)

mysql>

test DBが作成できた

testtblを作成する

USE test;
CREATE TABLE testtbl (
id INT,
item VARCHAR(50),
comment VARCHAR(250)
);
SHOW TABLES;


+—————-+
| Tables_in_test |
+—————-+
| testtbl |
+—————-+
1 row in set (0.01 sec)

mysql>

DESCRIBE testtbl;


+———+————–+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+———+————–+——+—–+———+——-+
| id | int | YES | | NULL | |
| item | varchar(50) | YES | | NULL | |
| comment | varchar(250) | YES | | NULL | |
+———+————–+——+—–+———+——-+
3 rows in set (0.01 sec)

mysql>

ん〜できた

データを追加してみるか

INSERT INTO testtbl (id, item, comment) VALUES (1, 'Apple', 'This is a red apple');
INSERT INTO testtbl (id, item, comment)
VALUES
(2, 'Banana', 'This is a yellow banana'),
(3, 'Orange', 'This is an orange fruit');

SELECT * FROM testtbl;


+——+——–+————————-+
| id | item | comment |
+——+——–+————————-+
| 1 | Apple | This is a red apple |
| 2 | Banana | This is a yellow banana |
| 3 | Orange | This is an orange fruit |
+——+——–+————————-+
3 rows in set (0.00 sec)

mysql>

できた

修正(UPDATE)

 update testtbl set item='bunchan' where id=2;

Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0

SELECT * FROM testtbl;

+——+———+————————-+
| id | item | comment |
+——+———+————————-+
| 1 | Apple | This is a red apple |
| 2 | bunchan | This is a yellow banana |
| 3 | Orange | This is an orange fruit |
+——+———+————————-+
3 rows in set (0.00 sec)

mysql>

削除(DELETE)

delete from testtbl where id=2;

Query OK, 1 row affected (0.02 sec)

SELECT * FROM testtbl;

+——+——–+————————-+
| id | item | comment |
+——+——–+————————-+
| 1 | Apple | This is a red apple |
| 3 | Orange | This is an orange fruit |
+——+——–+————————-+
2 rows in set (0.01 sec)

mysql>

いいね〜

Arduino IDE 2.3.4

今まで使っていたArduino開発用PCが、もたつく・・・

漢字変換すら遅くなってしまい、息継ぎ状態・・・

Thinkpad X-280のi3モデルなので
メモリも4GBがそもそものボトルネックか・・・

Windows11にしてから、よけいに動きがにすい

そこで、別のPCに引っ越しすることにした。

Thinkpad X380 Yogaが空いていたので
そこに最新のArduino IDE2.3.4をインストール

今までのソースたちの移動も今後のことを考えて
Googleドライブで共有することにした。

GdrivePC版をインストールして、Gドライブが割り当てられるので
そこにArduinoフォルダーをおいて、そこに見に行くように設定を変える。

G:\マイドライブ\Arduino\arduino

しばらく、様子見てみる・・・

IISのログって9時間ずれる

IISを立ててます。

仕事でIISをつかったアプリを開発してるのですが
今まで、ログの日付時刻がJSTではないことに気が付きませんでした。

デフォルトのままだと

サイトのIISのログ記録の形式を「IIS」にすると
ログ内の時刻がJSTで出力された。

IIS 10.0 でログが9時間ずれているときの対応【Windows Server 2016】|No IT No Life – おすぎやん サーバの設計・構築 (server-network-info.blogspot.com)

そもそも、ログはNLogで自前でだしていたので、見てなかった・・・

BLAZOR SERVERで開発
.NET5.0なので、上げたいが、客先サーバーの要件で・・・

動作確認中
WindowsServer2012R2:IIS8.5
WindowsServer2019:IIS10.0