简体   繁体   中英

MySQL VB.Net Connection Problems

I have setup a MySQL database locally and using the MySQL Workbench, i have setup accounts on which i can access later but when i tried to connect using VB.Net, i have receive an error "Access denied for user root@localhost (using password: YES)". I have tried to grant all the privileges to root but still getting the same error. I am using MySQL Connector 5.*

 string connStr = "server=localhost;user=root;database=reportdata;password=root!@#";
        MySqlConnection conn = new MySqlConnection(connStr);

but when i tried this:

 string connStr = "server=localhost;user=root;database=mysql;password=";
        MySqlConnection conn = new MySqlConnection(connStr);

It connected successfully.

Hoping that someone can help me on this, its dragging me like 4 hours now.

Thanks.

Root user of mysql doesn't have password by default.

Check this please for more details https://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html

Please log onto the MySQL console and change the password to what you desire:

MySQL 5.7.5 and Before 

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root!@#');

5.7.6 and Later

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root!@#';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM