MySQL rejects valid password via Command line on Windows [closed] - mysql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
After successfully creating new users 'u1' and 'u2' in mysql.user table and setting their passwords to pass and PASSWORD('pass') respectively, I am unable to log in as either user. Please review the commands below and help me figure out what I'm missing. Note that each concealed password is just the string "pass"
Why is access denied? Note that I was the root user (with all privileges) when I created the users u1 and u2

CREATE USER 'u3'#'localhost' IDENTIFIED BY 'pass';
CREATE USER 'u4'#'localhost' IDENTIFIED BY 'pass';
A good question from the OP prompted this: The two users just created above have basically no privileges to the server yet, except to login and sit there. They are awaiting the Grant command to allow them various access rights to certain databases.
Then try them. There is a reason the create user command was created.
After that you deal with grants to particular databases. And revisit the host issue.
But this is just a test.
Then to login from o/s command line, it is mysql -uu3 -p and ENTER. You will then be prompted for password. It is highly recommended not to login as root unless you know you are doing maintenance. Also, do not bake the password into a script file such as mysql -uu3 -ppass as your file could be poached and your password too. Note, no space after -u and -p in my example.
And yes, with the -p switch, when you are prompted for password, it is not visible.
Create User command from the Manual.
Drop User command from the Manual.
Grant command from the Manual. Be very careful not to use wildcards and WITH GRANT OPTION with the Grant command. You need to be careful to grant the minimal rights for users necessary for them, versus being lazy and applying wildcards.

Have you tried restarting the server before connecting? From The MySQL Documentation:
If you modify the grant tables directly using statements such as INSERT, UPDATE, or DELETE, your changes have no effect on privilege checking until you either restart the server or tell it to reload the tables. If you change the grant tables directly but forget to reload them, your changes have no effect until you restart the server. This may leave you wondering why your changes do not seem to make any difference!

Related

MySQL - Restrict access to a database

Is there a way to restrict users from accessing a particular database/schema within MySQL?
I want to create a database/schema that only I can access.
I also want to change the password of the "mysql" user but I do not see this user in the mysql.user table even though I was able to use this user to login to mysql.
I tried changing the password of the user by executing the statement -
mysqladmin --user=mysql --password=oldpassword password "newpassword".
But now I am not able to login this user altogether. I've tried both the old and the new passwords.
I am wondering if my changing this password can impact any mysql service running on the system.
For restricting table and schema you can use the GRANT, you can set permission for each user or group on a particular tables for more details :
Tutorial on Grant for mysql
For your access the answer is already on stackoverflow :How do I retrieve my MySQL username and password?
Hope that can help you

Access MySQL databases with only root password [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
so I have a dilemma. I am taking over from another developer and there's a box to which I only have root access, and I need to download the MySQL database from it. So I root in, and type mysql in the command line and get:
Access denied for user 'root'#'localhost' (using password: NO)
Then, I try mysql --user=root --password={myrootpassword} and it says:
Access denied for user 'root'#'localhost' (using password: YES)
I have no other information than the root password. Obviously this should be enough; how do I access my databases? Is the solution to create a new MySQL username?
Stop the mysql daemon, and start it up again with the --skip-grant-tables option. Once it's started up, you'll be able to log in as root with no password. You can do everything with the databases, change passwords, all that.
Note, you and everyone else will be able to log in without a password. You'll probably want to block off port 3306 or take the machine off the internet altogether til you're done what you need to do.
Once you've gotten the data or changed passwords or whatever, stop the service again and restart it normally to reenable permissions.
MySQL root and server root are two different accounts. Even if you have server root access it won't necessarily mean its same as MySQL root. However with server root access you can change MySQL root password. Depending upon the administration panel installed on your server there can be many different ways to do that.
First login as root
su root;
You can then set password by
root paswd;
It will ask for password, u can set whichever u wish.
Then logout from their & login as root as Username

Launching MySQL without a password [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have installed MySQL. During the process of installation I was asked whether I want to determine a password for root user. Well, I entered a password.
Now I can access it through
mysql -u root -p
Well, it works.
The question is what will happen if I use just mysql command?
Well. This is what appears:
mysql>
I'm a bit confused. If I organize a password, how can I get access without entering it.
What privileges do I have in this case?
You are connected as ROOT (you can create,detele, alter,procedures,triggers,tables,configurations, users, Dbs, etc) , so you can do whatever you want. It's the same if you do:
mysql -u root -p
or
mysql -u root -p "my_root_pass"
(of course if you have one)
the mysql> just mean that you are connected to your database, however it's not recommended that use that user, also you should give him a password with the grant command.
if you want to see the user that you are using, you can use:
mysql> select current_user;
The fact that you can "enter" MySQL doesn't mean that you have the ability to do anything. Try and create a database without supplying a password. Try and access a database without the password... I'm fairly sure that you won't be able to do either.
Try to access your database / tables when you see mysql> If it doesn't give you an error, then your password most likely is still not set for the root account. If this is the case, you can go ahead and execute this query to set your root password.
grant all privileges on *.* to 'root'#'localhost' identified by 'your new password';

delete MySQL entire database. Database not showing in MySQL Databases

Every time I create a database using a custom joomla template quick install the database is created but does not show up in MySQL Database management despite the fact that it most definitely does exist and MySQL database management knows it does because it wont let me create a database with that name due to error "Database already exists".
I want to delete joomlasall database.
Full size image
http://img99.imageshack.us/img99/4995/tempkh.png
If you can not see database but you are sure that it exists, this is definitely permissions issue.
Do
SHOW GRANTS
More info here
You will see that you does not hold global SELECT privilege.
You need to explicitly GRANT permissions with similar command like:
GRANT ALL PRIVILEGES ON DBNAME.* TO 'username'#'localhost';
Instead of ALL you can specify SELECT, INSERT, UPDATE, DELETE , EXECUTE, etc... check this
replace DBNAME with your DB name, username with user for whom you want to grant access and localhost with hostname if DB is used remotly.
To do this, you need GRANT privilege or to be root user.
use same mysql user credentials for Joomla DB connectivity also the one you are using in phpmyadmin.

What permission is required for a MySQL user to create a database?

Is it possible for a user other than root to create a database?
GRANT SELECT, CREATE ON *.* TO 'myguy'#'thatmachine' IDENTIFIED BY PASSWORD '*12057DFA2BFBD8760D4788735B1C3E26889D7ECE' |
GRANT ALL PRIVILEGES ON `db1`.* TO 'myguy'#'thatmachine'
GRANT ALL PRIVILEGES ON `db2`.* TO 'myguy'#'thatmachine'
I wonder what privilege is missing here? Also, why does the first line have a password attached to it?
UPDATE
Let me further clarify what the point of my question is. I have two database machines, source and target. There are many customer databases on the source machine. I need to move those source databases to the other target machine.
The databases are in the form of mysqldump'ed .sql files, which are sftp'd from source to target. Target user, not root, must then recreate the databases locally from each .sql file, perform some actions, then drop the database.
I can't find a way to give these privileges to the target user without giving him global privileges on *.*, which effectively makes that user as dangerous as root.
Absolutely you can.
http://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html#priv_create
As Izkata and Evan Donovan have mentioned in the comments, the best way to achieve this is to give myguy all privileges on the database myguy_%.
You can do this with the following sql:
grant all privileges on 'myguy_%'.* to myguy#localhost identified by 'password';
This way you don't have to bother with other existing databases, and myguy is able to create new databases to his heart's content.
The password field is what that particular user's password is when logging into MySQL itself. I'm not exactly sure what you mean when you say you wonder what privileges are missing. What exactly are you trying to do?