Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Monday, July 28, 2025

建立MariaDB用戶

MariaDB 用户管理

以下是连接到 MariaDB 并创建新用户的步骤:

1. 连接到 MariaDB

mysql -u root -p
    

2. 创建一个新用户

CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
    

3. 授予所有权限

GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%';
    

4. 刷新权限

FLUSH PRIVILEGES;
    

以上步骤将帮助您在 MariaDB 中创建一个新用户并授予其所有权限。

Thursday, August 8, 2019

PHP: connect to mysql

首先要確保以下幾點︰
1. apache有沒有允許連接到接口,可以查看host設置->Directory->Allow from all
2. 數據庫的用戶有沒有權限在第二個host登入,如果沒有權限可能會出︰
Caught exception: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 0
如果真的有這個錯誤,請到用戶權限新增在這個host。
可參考這裏︰https://manage.accuwebhosting.com/knowledgebase/2200/How-to-Allow-Remote-Connection-to-MySQL-Server-in-Windows.html

Sunday, January 3, 2016

Error: java連接phpmyadmin時, 出現Access denied for user XXX

錯誤描述︰
java.sql.SQLException: Access denied for user 'XXX'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)

出現地點︰Connection conn = DriverManager.getConnection(dbUrl, dbUser, dbPassword);

解決方法︰在頁面中新增用戶的時候要用IP指定host,例如localhost的IP是127.0.0.1。有可能是因為本機不知道localhost是在哪裡。在頁面中選擇Add User後,填寫host的時候要用IP地址。