MariaDB 10.6にユーザー名を変更する

環境
Windows 10 64bit
MariaDB 10.6.4
書式
RENAME USER 変更前ユーザー名 TO 変更後ユーザー名
[, old_user TO new_user] …

使用例
1.現在作成済みのユーザー名の一覧を確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------------+
| User | Host |
+-------------+-----------------+
| arkgame22 | 172.20.10.4 |
| root | % |
| test05 | %.arkgame.com |
| root | 127.0.0.1 |
| root | ::1 |
| root | desktop-2nbj8il |
| arkgame22 | localhost |
| cft02 | localhost |
| mariadb.sys | localhost |
| root | localhost |
| test10 | localhost |
+-------------+-----------------+
16 rows in set (0.202 sec)
MariaDB [(none)]> select user,host from mysql.user; +-------------+-----------------+ | User | Host | +-------------+-----------------+ | arkgame22 | 172.20.10.4 | | root | % | | test05 | %.arkgame.com | | root | 127.0.0.1 | | root | ::1 | | root | desktop-2nbj8il | | arkgame22 | localhost | | cft02 | localhost | | mariadb.sys | localhost | | root | localhost | | test10 | localhost | +-------------+-----------------+ 16 rows in set (0.202 sec)
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------------+
| User        | Host            |
+-------------+-----------------+
| arkgame22   |  172.20.10.4    |
| root        | %               |
| test05      | %.arkgame.com   |
| root        | 127.0.0.1       |
| root        | ::1             |
| root        | desktop-2nbj8il |
| arkgame22   | localhost       |
| cft02       | localhost       |
| mariadb.sys | localhost       |
| root        | localhost       |
| test10      | localhost       |
+-------------+-----------------+
16 rows in set (0.202 sec)

2.ユーザー名を変更します
arkgame22@localhost の名前をnewarkgame@localhost へ変更します
操作例
MariaDB [(none)]> rename user arkgame22@localhost to newarkgame@localhost;
Query OK, 0 rows affected (0.155 sec)

3.対象ユーザーの名前を変更することを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------------+
| User | Host |
+-------------+-----------------+
| arkgame22 | 172.20.10.4 |
| root | % |
| test05 | %.arkgame.com |
| root | 127.0.0.1 |
| root | ::1 |
| root | desktop-2nbj8il |
| cft02 | localhost |
| mariadb.sys | localhost |
| newarkgame | localhost |
| root | localhost |
| test10 | localhost |
+-------------+-----------------+
16 rows in set (0.001 sec)
MariaDB [(none)]> select user,host from mysql.user; +-------------+-----------------+ | User | Host | +-------------+-----------------+ | arkgame22 | 172.20.10.4 | | root | % | | test05 | %.arkgame.com | | root | 127.0.0.1 | | root | ::1 | | root | desktop-2nbj8il | | cft02 | localhost | | mariadb.sys | localhost | | newarkgame | localhost | | root | localhost | | test10 | localhost | +-------------+-----------------+ 16 rows in set (0.001 sec)
MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------------+
| User        | Host            |
+-------------+-----------------+
| arkgame22   |  172.20.10.4    |
| root        | %               |
| test05      | %.arkgame.com   |
| root        | 127.0.0.1       |
| root        | ::1             |
| root        | desktop-2nbj8il |
| cft02       | localhost       |
| mariadb.sys | localhost       |
| newarkgame  | localhost       |
| root        | localhost       |
| test10      | localhost       |
+-------------+-----------------+
16 rows in set (0.001 sec)

 

MariaDB

Posted by arkgame