Connect with MySQL Database MacOs Ventura 13.4
-
Hi,
Where exactly do you get these errors ?
It looks like you are trying to run several MySQL instance at the same time.@SGaist To be honest before I installed Qt Creator I downloaded MySQL and Xampp. When I run both I can see my database via localhost / phpadmin. Now after added plugin to Qt Creator I can't connect with database via Qt app. I can see this error when I click "Initialize Database" button. I can't uninstall MySQL because I need it for my QMySQL Plugin. I think you are right. I have more than one instance. But the question is how to disable it?
https://ddgobkiprc33d.cloudfront.net/9539ae1d-8662-47cf-b3b3-6768074ee978.png
-
@SGaist To be honest before I installed Qt Creator I downloaded MySQL and Xampp. When I run both I can see my database via localhost / phpadmin. Now after added plugin to Qt Creator I can't connect with database via Qt app. I can see this error when I click "Initialize Database" button. I can't uninstall MySQL because I need it for my QMySQL Plugin. I think you are right. I have more than one instance. But the question is how to disable it?
https://ddgobkiprc33d.cloudfront.net/9539ae1d-8662-47cf-b3b3-6768074ee978.png
One thing you are currently not doing is printing the QSqlDatabase error when the open call fails. That should give you a hint about what is going wrong.
Doesn't the XAMPP stack provide MySQL ? Here might be the doubling.
-
One thing you are currently not doing is printing the QSqlDatabase error when the open call fails. That should give you a hint about what is going wrong.
Doesn't the XAMPP stack provide MySQL ? Here might be the doubling.
@SGaist I decided to uninstall XAMPP for a testing time. I added this line of code to my connections function:
qDebug()<<db.lastError();
And I got this
QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
This is strange a bit...
-
@SGaist I decided to uninstall XAMPP for a testing time. I added this line of code to my connections function:
qDebug()<<db.lastError();
And I got this
QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
This is strange a bit...
Are you sure the root user is configured to be accessible on localhost ? I don't think the default configuration allows that.
-
Are you sure the root user is configured to be accessible on localhost ? I don't think the default configuration allows that.
@SGaist Ok. So I decided to fix this issue. I follow this solution for root:
https://stackoverflow.com/questions/50177216/how-to-grant-all-privileges-to-root-user-in-mysql-8-0
I input:
mysql -u root -p
Then Input password and the result is:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.33 MySQL Community Server - GPL Copyright (c) 2000, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Next I input:
CREATE USER 'root'@'%' IDENTIFIED BY '11111111';
Output:
Query OK, 0 rows affected (0,01 sec)
Then I input:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Result:
Query OK, 0 rows affected (0,02 sec)
Finally I input:
FLUSH PRIVILEGES;
And the result:
Query OK, 0 rows affected (0,00 sec)
Next I run my Qt Creator project and the error still exists.
QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
I also checked port 3306 via
sudo lsof -i -P | grep LISTEN | grep :3306
and I got :
mysqld 28777 _mysql 18u IPv6 0x8a0d66b153d9f2cf 0t0 TCP *:33060 (LISTEN) mysqld 28777 _mysql 20u IPv6 0x8a0d66b153d9cacf 0t0 TCP *:3306 (LISTEN)
-
@SGaist Ok. So I decided to fix this issue. I follow this solution for root:
https://stackoverflow.com/questions/50177216/how-to-grant-all-privileges-to-root-user-in-mysql-8-0
I input:
mysql -u root -p
Then Input password and the result is:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.33 MySQL Community Server - GPL Copyright (c) 2000, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Next I input:
CREATE USER 'root'@'%' IDENTIFIED BY '11111111';
Output:
Query OK, 0 rows affected (0,01 sec)
Then I input:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Result:
Query OK, 0 rows affected (0,02 sec)
Finally I input:
FLUSH PRIVILEGES;
And the result:
Query OK, 0 rows affected (0,00 sec)
Next I run my Qt Creator project and the error still exists.
QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost' (using password: NO)")
I also checked port 3306 via
sudo lsof -i -P | grep LISTEN | grep :3306
and I got :
mysqld 28777 _mysql 18u IPv6 0x8a0d66b153d9f2cf 0t0 TCP *:33060 (LISTEN) mysqld 28777 _mysql 20u IPv6 0x8a0d66b153d9cacf 0t0 TCP *:3306 (LISTEN)
@BushyAxis793 silly question but: did you use the correct password ?
-
@BushyAxis793 silly question but: did you use the correct password ?
@SGaist I'm sure the password is correct. I set it during mysql installation process.
-
@SGaist I'm sure the password is correct. I set it during mysql installation process.
@BushyAxis793
But have you changed yourdb.setPassword("");
to include it? The error messageAccess denied for user 'root'@'localhost' (using password: NO)
implies you are not passing any password to logon as root.
-
@BushyAxis793
But have you changed yourdb.setPassword("");
to include it? The error messageAccess denied for user 'root'@'localhost' (using password: NO)
implies you are not passing any password to logon as root.
-
-
@BushyAxis793 one last thing: making your root account available on any and all point of access of your MySQL server is a wrong idea. You should rather create a dedicated user that has access to a specific database for that purpose.