mariadb修改密码
时间: 2023-10-26 09:07:44 浏览: 101
要在MariaDB中修改密码,有几种方法可以选择。如果你知道原密码,可以使用SET PASSWORD命令或UPDATE命令进行修改。例如,你可以在终端输入以下命令来修改密码:
```
mysql -uroot -p
```
然后输入原密码。接下来,输入以下命令来修改密码:
```
SET password for 'root'@'localhost' = password('newpassword');
```
或者,你也可以使用以下方法之一来修改密码:
方法一:
```
mysql -uroot
```
然后输入以下命令:
```
use mysql;
UPDATE mysql.user SET password = PASSWORD('newpassword') WHERE user = 'root';
FLUSH PRIVILEGES;
```
方法二:
```
mysql -uroot
```
然后输入以下命令:
```
use mysql;
SET password=PASSWORD('newpassword');
FLUSH PRIVILEGES;
```
方法三:
```
mysqladmin -u root password 'newpassword'
```
如果你的root用户已经设置过密码,可以使用以下方法来修改密码:
```
mysqladmin -u root -p 'oldpassword' password 'newpassword'
```
无论选择哪种方法,都可以通过修改密码来保护你的MariaDB数据库。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [修改MySql/MariaDB密码](https://blog.csdn.net/oWangChen1234567/article/details/78681647)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [MariaDB设置初始化密码及修改密码](https://blog.csdn.net/sqlquan/article/details/119039555)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文