When I'm logged into Linux as root (or sudo), I thought when I typed mysql that MySQL used the current username and password of the Linux user, however, when I try that, it just gives error ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO). I don't want to disable requiring a password, I just want it passed from the current user if they're not specified (I've already disabled anonymous users too).
If you don't specify the username, MySQL on Linux uses the username of the calling process, but not the password belonging to that user.
The password of the caller is not available to applications on Linux, and I think this is for the best!
By default, MySQL authenticates against an internal table of users and passwords that has nothing to do with the operating system's passwd file. The fact that MySQL instances often have a user called 'root' is coincidence; the MySQL 'root' is not the same as the Linux 'root', and they can (and should) have different passwords.
If you want to avoid the requirement to type a password every time, you should save a default user/password in $HOME/.my.cnf:
[client]
user = scott
password = tiger
(I recommend against storing the superuser password in this file.)
In MySQL 5.6, they introduces a new feature to store login credentials more securely. See https://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html
Turn on the option AllowNoPassword on file /etc/phpmyadmin/config.inc.php.
Edit the file config.inc.php, search and uncomment this line:
// $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
if it's set to false make it true and restart the Mysql Service and you are good to go
Then you can access PhpMyAdmin/MySQl Console without password.
just put an alias in your .bashrc:
alias mysql="mysql -u root -pYourPassWord"
Related
I had one admin user with username = root (had admin privileges) and password =admin then i created new user with username =root (have no privileges) and password =root. but what happened now I have lost access to root user(admin) and i am able to access only root user which is newly created.now i am unable to do anything with this newly created root user. it show access denied for every operation. so is there any way to gain access to root(admin) user or give admin privileges to new root user or reset databases and start by new. I tried many solution but none of them worked for me.
Complete account name includes both username part and host part. See Specifying Account Names and the difference between USER() and CURRENT_USER().
Check complete names for both root accounts. Then log in by the way which makes "old" root account matched one only.
For example, if "old" is 'root'#'%' and "new" is 'root'#'localhost' or 'root'#'127.0.0.1' then disable network connections (--skip-networking=ON in the service command line) and connect using named pipes or shared memory (on Windows) or Unix socket files (on Unix). Or connect to the server remotely.
Whenever I try to login via SSH on my MySQL server, the 'root' user does not require me to provide a password.
I already tried the suggestion from this guide, however, I still have no luck.
UPDATE mysql.user
SET authentication_string = PASSWORD('MyPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
and
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyPass';
I manage my database using phpMyAdmin and when I checked my user groups, before it says that 'root' doesn't have a password but when I tried the codes above, it changed the password to 'Yes', but still allows me to login as root via ssh.
Another problem is I cannot login using the 'root' user in phpMyAdmin.
By the way, im using MySQL 5.7.21 for Debian9
Update 4/10:
Some googling lead me to threads that says later version of MySQL/phpMyAdmin does not allow root to login anymore, but a month ago I was able to do it, unfortunately I forgot the steps that I did..
Can you check if you have a .my.cnf file in your home folder or in /etc/mysql/ ?
It could contain root credentials.
Also can you print the complete contents of your users table? There might be another entry giving root permissions when connecting locally.
Does anyone know why I would be getting an Access Denied error using XAMPP on OS X?
When I go to localhost/phpmyadmin I get the message #1045 - Access denied for user 'root'#'localhost' (using password: YES)
and when I go to just localhost I get
Access forbidden!
You don't have permission to access the requested directory. There is
either no index document or the directory is read-protected.
Is this a permissions issue? I added the password root to the username root in the phpmyadmin config file, but that didn't work and it wouldn't explain why I am getting the error on localhost as well. What IS working is the virtual host I created called my.server, but other than that, I seem to be locked out for some reason.
This error:
#1045 - Access denied for user 'root'#'localhost' (using password: YES)
Is a MySQL error. That's saying that there was an attempt to connect to the MySQL server, and either the specified user account doesn't exist, or the passwords don't match. From another client that can connect, verify the user account exists
SELECT u.user, u.host, u.password
FROM mysql.user
WHERE u.user = 'root'
AND u.host = 'localhost'
If the password column is empty, then there's no password on that account. If there's a '*688D...' value in there, you can compare the value of the hash of the password you're supplying...
SELECT PASSWORD('mysecretpassword')
Also, I'd recommend you create a DIFFERENT database user account (other than 'root'#'localhost', for use by your PHP scripts. (As one advantage, this will allow you to apply the security principle of "least privilege", granting only the privileges required.
The other error is saying that the webserver isn't configured to allow access to the URI you've specified, in the case of "http://localhost/", the webserver isn't configured to allow access to the ROOT of the webserver directory. (This is usually a really a good thing, in terms of security, not exposing the contents of this directory.)
I'm using IIS with PHP, PHPMyAdmin and mysql. They were installed separately. When mysql was installed, I was given the option to and went ahead with setting a password. I can use phpmyadmin using the same password, but when I test my database connection I receive the error Access denied for user ''#'localhost' (using password: NO).
I've been all over forums and youtube looking for a possible solution but haven't been able to get anywhere. I have disabled my firewall and attempted to allow mysqld through it separately and still no results.
PHPMyAdmin resides in my wwwroot folder for IIS and mysql is in my C:/Progam Files folder. Is this the possible issue or is this set up okay?
Additionally, I've reviewed my config files and all have the same matching password. My user is root and all config files have that as well. PHPMyAdmin accepts that as the user.
What it seams to me is that your phpMyAdmin is not correctly configured. You lack username and password options thus you cannot connect. You should review: http://docs.phpmyadmin.net/en/latest/config.html#basic-settings and look for $cfg['Servers'][$i]['nopassword'] option. It should be disabled.
P.S.: Do you get username/password prompt from phpmyAdmin ?
It looks like you are giving user as username under config.inc.php without any password..
You can either provide the correct password for username user
or
You can provide the same username and password which lets you login to mysql from command prompt..
Hi Mysql and Linux gurus!
I have run into a weird behavior issue with Mysql server install on my local machine. Here is the history -
I normally operate as a non root user, and use su to get root priviledges for installs.
I installed MySQL 5.1 server on my Fedora Linux machine 13
I made it necessary for MySQLs root user to have a password when connecting using the mysql client from localhost
This is what i need - I need to test a shell script which calls the mysql client without username and password, I need to remove the password for mysqls root user. Also (importantly), the script should run from the root user of my computer.
mysql -D dbname < script.sql
This is what i did - From my non-root linux account i started mysql client, logged in as root#localhost, and ran the following command to remove the root#localhost password
update user set password = PASSWORD('') where user = 'root' and host = 'localhost';
The issue! - Now from my non-root unix account when i run just mysql it successfully logs me in. (so far so good). But when i do su, login as linux root (super user) and run mysql - I get
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Post Script - I have logged in with an alternate account from the super user account and re-run the query to update the user, It still didn't work. How come I can run mysql client without username and password as a non-root user, but cannot do the same as a linux super user???
Any help will be appreciated
After updating GRANTS or the mysql tables directly, many people forget to execute FLUSH PRIVILEGES.
Only after FLUSH PRIVILEGES, changes take effect.
MySQL accounts are completely independent from system accounts. They may coincidentally have the same usernames (like the default root account being the system AND mysql super-user accounts).
Once you've set a password on an account in mysql, you have to force the mysql monitor (mysql command) to prompt for a password (-p) option, and possibly specify your MySQL username (-u option) if your MySQL account name doesn't match your Linux username:
In other words:
mysql -u root -p
will tell MySQl to try and log you into the mysql root account, and to prompt for the account's password.