Access MySQL databases with only root password [closed] - mysql

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

Related

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

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!

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';

How to reset MySQL root user password and privileges

I assigned a password to the root MySQL user in XAMPP some times ago. I recently tried to undo that and give it no password but it's not working.
I tried setting the password to an empty string using mysqld --skip-grant-tables and then using the mysql command line directly. It looks like it works, the root user no longer has a password, however if I login in PhpMyAdmin I cannot see any of my databases, only an "information_schema" and a "test" database. If I look at the User tab, it seems to have all the privileges though:
Any suggestion on how to fix this issue?
Note: I checked with the command line, all my databases and tables are still there, I just cannot see them in PHPMyAdmin.
Try removing the anonymous user who is allowed to connect from any host. My feeling is that that row is taking precidence over the row for root when MySQL validates the login.
If you have removed that Anonymous user and the issue still occurs, try setting a password to root and the host to localhost then connect again.

MySQL munging username on linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about programming within the scope defined in the help center.
Improve this question
I'm writing a script to perform some database maintenance, and MySQL is not accepting the username I'm trying to pass it.
I have a MySQL user and database named 'abc_wpsites', as well as a user and database named 'abc_wpsitesdev'. Here, I'm trying to access abc_wpsitesdev, but MySQL continually attempts to access with the account 'abc_wpsites' instead.
abc.com [~]# mysql -uabc_wpsitesdev --password='(redacted)' -h localhost abc_wpsitesdev
ERROR 1045 (28000): Access denied for user 'abc_wpsites'#'localhost' (using password: YES)
abc.com [~]# mysql --user='abc_wpsitesdev' --password='(redacted)' -h localhost abc_wpsitesdev
ERROR 1045 (28000): Access denied for user 'abc_wpsites'#'localhost' (using password: YES)
abc.com [~]# mysql --user='abc_wpsitesfff' --password='(redacted)' -h localhost abc_wpsitesdev
ERROR 1045 (28000): Access denied for user 'abc_wpsites'#'localhost' (using password: YES)
Notice how each attempt at experimenting with the username still results in an attempt to access MySQL via the 'abc_wpsites' account. Any thoughts on what's going on here?
Also, I should mention that I can connect via other methods with the appropriate credentials (e.g. via MySQL), so this seems to be some sort of problem with my understanding/the operation of MySQL's CLI interface.
I wouldn't suggest passing your login information that way. This means your password is
Visible in the processlist (some distro's will filter that but)
It's either stored in a crontab or your bash .history file
Instead create at script.cnf file that is NOT world readable.
The contents will look like
[client]
user=abc_wspitesdev
password=your_password
Change your command line call to
mysql --defaults-file=/path/to/script.cnf -h localhost abc_wpsitesdev
mysql
Edit
Your other comment said you could connect as other users. If you have root access to this db run
select user, host, passowrd from mysql.users;
Compare the one that's not working with others that are.
The passwords that are stored will be hashes of the actual values. Are they all the same length? If one is significantly longer or shorter it could be the password was stored with an old password hashing method used in versions 4.x and earlier.
What is the host for the account you are trying to connect through? Is it 'localhost' or an IP address? If it is your IP address this likely might be the problem. Since your command line call is connecting to localhost this will tell it to connect through a unix socket (/var/lib/mysql/mysql.sock perhaps). MySQL differentiates these connections from ones coming through the TCP stack.
You could alternatively specify your full (non 127.0.0.1) IP address on the commandline if this is the case like
mysql -u blah -pblah -h 1.2.3.4
"Where" is user "abc_wpsitesdev" allowed to connect from as opposed to where the "abc_wpsites" user is allowed to connect from -- any difference?
If you did "grant all privileges on abcwpsitedev to 'abc_wpsitesdev'#'%' identified by 'thedevpassword';" that won't work for accessing from localhost as explained in the last pargraph in the post from the manual below:
From the MySQL manual:
After connecting to the server as root, you can add new accounts. The following statements use GRANT to set up four new accounts:
mysql> GRANT ALL PRIVILEGES ON . TO 'monty'#'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON . TO 'monty'#'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON . TO 'admin'#'localhost';
mysql> GRANT USAGE ON . TO 'dummy'#'localhost';
The accounts created by these statements have the following properties:
Two of the accounts have a user name of monty and a password of some_pass. Both accounts are superuser accounts with full privileges to do anything. The 'monty'#'localhost' account can be used only when connecting from the local host. The 'monty'#'%' account uses the '%' wildcard for the host part, so it can be used to connect from any host.
It is necessary to have both accounts for monty to be able to connect from anywhere as monty. Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when monty connects from the local host. As a result, monty would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'monty'#'%' account and thus comes earlier in the user table sort order. (user table sorting is discussed in Section 5.5.4, “Access Control, Stage 1: Connection Verification”.)
the problem with your line
mysql -uabc_wpsitesdev --password='(redacted)' -h localhost abc_wpsitesdev
is, that you need a space after -u
(and no space after -p)
this is the form I use:
mysql -u abc_wpsitesdev -p(redacted) -h localhost abc_wpsitesdev

In MySQL workbench what is username/password for connection? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm new to MySQL. I'm doing the tutorial and trying to create a connection. I need to have a username and password. I get an error each time saying it
can't connect to username#localhost using password YES.
I'm just trying to set this up locally. What are the username and password supposed to be? How is the account created, where can I find it, etc? I am using Windows.
Thanks,
Good day Agezna
In MySql Workbench the username and password are the username and password of you MySql Server user. But once you don't know those as well.
Have you installed MySql Server alone from MySql website?
Or MySql Server was included in some web server applications bundle like:
Xampp. Default username is root and there is no password set.
Wampp. Default username is root and there is no password set.
other one? Try the same for Xampp if it doesn't work, specify the bundle name then i can help you.
If you installed MySql Server alone, the password was set at installation, if you need to change it, there is a executable in your MySql Server folder in your Start Menu in Windows where you can change the configuration of you server, including your default password.
Regards.
You are being prompted for a username and password for your MySQL server. If this is a fresh server installation, as others have said, the username root with a blank password should get you in initially. If this doesn't work you can always reset the root password if you have shell access. There are instructions here:
http://www.cyberciti.biz/tips/recover-mysql-root-password.html
When you installed, did you set a root password? If so, use username "root" and the password you set. If not, leave "password" empty.