mariadb10.6忘记密码-windows

发布时间 2023-07-05 07:38:54作者: 1420_wafer

### 结束进程 ###

mariadb10.6的服务不叫"mariadb"
C:\Users\Administrator>tasklist |findstr mariadb

 

查看服务名"mysql"的进程号(PID号是5636,因每次都不同,所以用一次查看一次)

C:\Users\Administrator>tasklist |findstr mysql
mysqld.exe 5636 Services 0 47,116 K

 

结束该进程号

C:\Users\Administrator>taskkill /pid 5636
ERROR: The process with PID 5636 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).

这里要加参数(/f),强制执行

C:\Users\Administrator>taskkill /pid 5636 /f
SUCCESS: The process with PID 5636 has been terminated.

 

### 跳过验证 ###

我的安装目录是默认的在C盘

下面这条命令不适合我这个版本
C:\Program Files\MariaDB 10.6\bin>mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
'mysqld_safe' is not recognized as an internal or external command,
operable program or batch file.

 

mariadb用这条命令跳过验证

C:\Program Files\MariaDB 10.6\bin>mysqld --defaults-file="c:\Program Files\MariaDB 10.6\data\my.ini" --console --skip-grant-tables
2023-07-05 6:28:13 0 [Note] Starting MariaDB 10.6.12-MariaDB source revision 4c79e15cc3716f69c044d4287ad2160da8101cdc as process 9336
2023-07-05 6:28:13 0 [Note] InnoDB: Compressed tables use zlib 1.2.12
2023-07-05 6:28:13 0 [Note] InnoDB: Number of pools: 1
2023-07-05 6:28:13 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2023-07-05 6:28:13 0 [Note] InnoDB: Initializing buffer pool, total size = 2147483648, chunk size = 134217728
2023-07-05 6:28:13 0 [Note] InnoDB: Completed initialization of buffer pool
2023-07-05 6:28:13 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=42730,42730
2023-07-05 6:28:14 0 [Note] InnoDB: 128 rollback segments are active.
2023-07-05 6:28:14 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
2023-07-05 6:28:14 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2023-07-05 6:28:14 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2023-07-05 6:28:14 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2023-07-05 6:28:14 0 [Note] InnoDB: 10.6.12 started; log sequence number 42742; transaction id 14
2023-07-05 6:28:14 0 [Note] Plugin 'FEEDBACK' is disabled.
2023-07-05 6:28:14 0 [Note] InnoDB: Loading buffer pool(s) from C:\Program Files\MariaDB 10.6\data\ib_buffer_pool
2023-07-05 6:28:14 0 [Note] Server socket created on IP: '::'.
2023-07-05 6:28:14 0 [Note] Server socket created on IP: '0.0.0.0'.
2023-07-05 6:28:14 0 [Note] InnoDB: Buffer pool(s) load completed at 230705 6:28:14
2023-07-05 6:28:14 0 [Note] mysqld: ready for connections.
Version: '10.6.12-MariaDB' socket: '' port: 3306 mariadb.org binary distribution


### 修改root密码 ###

另外再开一个commond窗口,空密码进入。
C:\Users\Administrator>mariadb -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.6.12-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

 

查看数据库

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.002 sec)

 

使用"mysql"数据库

MariaDB [mysql]> use mysql;
Database changed

 

更新root密码,不成功

MariaDB [mysql]> update user set password=password('123456789') where user='root';
ERROR 1348 (HY000): Column 'Password' is not updatable

 

换一种方式,提示正在运行前面的跳过"--skip-grant-tables"。需要刷新一下先

MariaDB [mysql]> alter user 'root'@'localhost' identified by '123456789';
ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement

 

刷新

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.056 sec)

 

再试一次更新密码,成功

MariaDB [mysql]> alter user 'root'@'127.0.0.1' identified by '123456789';
Query OK, 0 rows affected (0.037 sec)

 

再次刷新一下

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [mysql]> quit;
Bye


### 关闭跳过窗口 ###

关闭跳过用的窗口

Ctrl+c
或,直接关闭挂起的窗口


### 启动mariadb服务 ###

用"net start 服务名称"启动mariadb数据库
C:\Users\Administrator>net start mariadb
The MariaDB service is starting.
The MariaDB service was started successfully.


### 重新登录mariadb ###

重新登录mariadb,输入新密码
C:\Users\Administrator>mariadb -uroot -p
Enter password: *********
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.6.12-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

 

### 这是IP方式登录 ###
C:\Users\Administrator>mariadb -h 127.0.0.1 -uroot -p
Enter password: *********
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.6.12-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

### 这是IP+端口方式登录 ###
C:\Users\Administrator>mariadb -h 127.0.0.1 -P 3306 -uroot -p
Enter password: *********
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.6.12-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.