> ## Content Index
> Fetch the complete content index at: https://www.albert-yu.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# MySQL 與 MariaDB 安裝完畢後無密碼登入問題
- URL: https://www.albert-yu.com/blog/mysql-mariadb-passwordless-login-after-install/
- Published: 2019-05-30T13:21:53.000Z
- Updated: 2026-10-30T03:43:29.000Z
- Author: Albert Yu
- Tags: Databases, System, Linux, MariaDB, mysql, OS, Security, Ubuntu, 無密碼, 登入

這個問題主要出自於安裝完成後預設是『unix\_socket』

![](https://www.albert-yu.com/content/images/2026/10/mysql-yu-mariadb-an-zhuang-wan-bi-hou-wu-mi-ma-deng-ru-wen-ti-01.png)

這問題處理方式其實重點就在於要把它改成『mysql\_native\_password』

登入mysql後執行指令

```
UPDATE mysql.user SET authentication_string = PASSWORD('mypassword'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

```

這時候就會將密碼設定為 mypassword 並且修復問題

![](https://www.albert-yu.com/content/images/2026/10/mysql-yu-mariadb-an-zhuang-wan-bi-hou-wu-mi-ma-deng-ru-wen-ti-02.png)

執行完成後

這時候只需要將mysql重啟即可

同時密碼登入即可正常運作

![](https://www.albert-yu.com/content/images/2026/10/mysql-yu-mariadb-an-zhuang-wan-bi-hou-wu-mi-ma-deng-ru-wen-ti-03.png)