Understanding MySQL Password
Probably I can't get stupid anymore, but seriously this is the first time I had to think about it (first time a single-user app comes out of multiple users from multiple users). What is a MySQL (or any other database) password for? The password that we see in the connection strings is as if:
"SERVER=localhost;DATABASE=tree;UID=root;PASSWORD=branch;Min Pool Size = 0;Max Pool Size=200"
Is it the
codeword for the user
to access the database
? Or is it for
accessing any MySQL database on a specific machine? Or is it the password for any user to access the database
? Or a password for any user to access any MySQL database on that machine?
So my questions are mostly?
Is the password specific to MySQL, or database, or user? Or for this specific user for this specific database on this specific MySQL installation? Or any combination of them?
Can we have a password for MySQL itself (if not with
), can we have a password for db itself (if not with
Sorry for my ignorance;)
Edit: I can run this query to drop my database:
query = "DROP DATABASE tree";
with connection string:
"SERVER=localhost;UID=root;PASSWORD=branch;Min Pool Size = 0;Max Pool Size=200"
Doesn't that mean that the password is not for the database, but for the user?
source to share
1) Is the password specific to MySQL, or database, or user? Or for this specific user for this specific database for this specific MySQL installation? Or any combination of them?
Let me start from scratch. The first time you install MySQL, you are prompted for a username (say root) and a password (say root). This is for the whole server. After you connect to the server with the above username and password, you can create user accounts for various reasons, for example: "abc" with password "xxx" should only connect to one database, eg Test. And another user "xyz" with the password "aaa" can connect to the server and access all databases, but only with the SELECT privilege.
CREATE USER 'abc'@'%' IDENTIFIED BY 'xxx'; FLUSH PRIVILEGES; GRANT ALL ON `test`.* TO 'abc'@'%' WITH GRANT OPTION;
Here user 'abc' with password 'xxx' can connect to the server, but with minimal privileges - access only to the test database.
CREATE USER 'xyz'@'%' IDENTIFIED BY 'aaa'; FLUSH PRIVILEGES; GRANT SELECT ON *.* TO 'xyz'@'%' ;
This user - "xyz" with the password "aaa" connects to the server only with the SELECT privilege.
Thus, three users with different passwords can actually connect to the server as "root", with the password "root" having all privileges, while "abc" and "xyz" have least privileges.
I think I answered your second question as well :-)
source to share