Access denied for user 'root' - mysql

I downloaded an adobe flex mysql script (from a tutorial I am learning) and ran the script in my sql 5.5. It created a database, but it was stored in my wamp folder under:
C:\wamp\bin\mysql\mysql5.1.36\data
I have a test php page that is supposed to print out the data from the database (from the adobe tutorial).
But, when I load the test page from localhost/test.php it just says:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'#'localhost' (using password: YES) in C:\wamp\www\test.php on line 7
Error connecting to MySQL
And if I run it from localhost:3306/test.php I get just gibberish:
B???
5.1.36-community-log????nKm`zell?ÿ÷??????????????Z\Ap3JZcfVZD???ÿ„Got packets out of order
What password do I use -- my wamp password / login name, or the new mysql5.5 root password? I've tried the mysql5.5 root & password, but I still can't connect.
Why is mysql5.5 loading the database under my older WAMP sql data folder? Is there some conflict having MySQL5.1 installed with WAMP, and MySQL5.5 I just installed separately?

After wasting most of a day on this problem, it turned out that all i had to do was supply the non-localhost hostname. I've no idea why (the user is allowed to connect from Any host), but it works!
root#base:~# mysql -u username -h hostname -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
And in PHP:
Test 1807:
<?php
$username = "username";
$password = "password";
$hostname = "actualhostnamenotlocalhost";
$con = mysqli_connect($hostname, $username, $password);
// Check connection
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_close($con);
?>
OK.

Please verify if you are using the right password, with the help of phpMyAdmin or my sql work bench
if this is a fresh installation then you will not have any password for the root
You need to set the password and the start connecting to the database using the password that is set
also if you are able to run the script without specifying the password, that means, no password is set for the database
You can use the switch "use password" to NO and connect using root

Same problem after updating my phpmyadmin version, and turn out was the config problem:
step 1)open the corresponding phpmyadmin installation directory , duplicate config.sample.inc.php to config.inc.php under the same directory .
step 2)Open config.inc.php
change
$cfg['Servers'][$i]['AllowNoPassword'] = **false**;
to
$cfg['Servers'][$i]['AllowNoPassword'] = **true**;
and save the file.

I spent almost the whole day resolving this issue so if this help anyone I solved it by
using the following code:
// - Get Connection - //
$this->dbCon = mysqli_connect($this->dbHost,$this->dbUser) or
die("Connection failed:<br/>" . mysqli_connect_error());
// - Select Database - //
mysqli_select_db($this->dbCon,$this->dbName) or
die("Selection failed: <br/>" . mysqli_connect_error());
-and also by setting
$cfg['Servers'][$i]['AllowNoPassword'] = true - in the config.inc.php file.
Hope that helps

Related

MAMP MySQL Cannot connect: invalid settings.

I've run into a issue in my MAMP instillation, I didn't change anything it just happened. I start MAMP perfectly fine and it gives the green light that the MySQL server is up and I can connect to it from the terminal using the mysql command. However when I try and open phpMyAdmin I get this error:
Error
MySQL said: Documentation
Cannot connect: invalid settings.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
I didn't change the default username and password and have subsequently tried to reset them to root and root which is what phpMyAdmin thinks they are. However I still get this error. The host is still set to localhost. I've tried uninstalling and reinstall MAMP to no avail.
Change these two lines in config.inc.php file.
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '8889';
This should solve the problem.
Seems like a lot of people where having this error recently.
MAMP had changed the PHP toggle in the preferences pane to 7.0.8, just had to switch it back to 5.6.10.
You need to reset the mysql password for mamp.
I found that tech-otaku explains it well.---https://www.tech-otaku.com/local-server/resetting-mamp-mysql-root-user-password/
What he basically says in the link: Stop the servers. Then using the terminal:use the skip-grant-tables command, then --skip-networking command, and flush privileges command. He goes into more detail for the steps on his website.
P.S- You can also stop the mysqld server from the activity monitor. Applications/utilities/activitymoniter (search:mysql)
Find default mysql host, root and password using mamp on mac
I got this error too. I followed the path below to find out the default root, host and password information.
/Applications/MAMP/bin/mamp/index.php
*my $source = 'DBI:mysql:database=test;host=localhost;
my $user = 'root';
my $password = 'root';*
$db = new mysqli("localhost", "root", "root", "MyDatabaseName");

#1045 - Access denied for user 'root'#'localhost' (using password: YES)

This might seem redundant but I was unable to find a correct solution.
I was unable to login to mysql using the mysql console.It is asking for a password and I have no clue what I actually entered.(Is there a way to get the password or change it?)
This is how my config.inc look.
When I try to open phpmyadmin I get this error(#1045 - Access denied for user 'root'#'localhost' (using password: YES))
<?php
/* Servers configuration */
$i = 0;
/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'prakash123';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* End of servers configuration */
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';
?>
I have tried to uninstall( Plus Deleted all the related files) WAMP and reinstall.It didn't help either.
While reinstalling WAMP server it is not asking for any username password stuff I don't know why.
Any help is highly appreciated.
I first changed the root password running mysql at a prompt with
mysql -u root -p
Update password:
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
Edited line in the file config.inc.php with the new root password:
$cfg['Servers'][$i]['password'] = 'MyNewPass'
Stop and re-start mysql service (in Windows: mysql_stop.bat/mysql_start.bat)
and got phpMyAdmin to work!
EDIT 2017: for MySQL≥5.7 use authentication_string in place of Password (see this answer):
`UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root';
`
The problem was I have 2 instances of Mysql installed and I didn't know the password for both instances.Just check if port 80 is used by any of the programs.
This is what I did
1.Quit Skype because it was using port 80.(Please check if port 80 is used by any other program).
2.Search for Mysql services in task manager and stop it.
3.Now delete all the related mysql files.Make sure you delete all the files.
4.Reinstall
Well, there are many solutions already given above. If there are none of them works, maybe you should just try to reset your password again to 'root' as described here, and then reopen http://localhost/phpMyAdmin/ in other browser. At least this solution works for me.
This worked for me.
In your config file
$cfg['Servers']['$i']['password'] = 'yourpassword';
In your mysql shell, login as root
mysql -u root
change your password or update if you've forgotten the old one
UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';
stop and restart your mysql server from the xampp control panel. phpmyadmin can login to see your databases
mysql.exe->Run as administrator or go to following path C:\wamp\bin\mysql\mysql5.5.24\bin and than right click on mysql.exe go to properties and than select tab as Compatibility and see the bottom of dialog box in privilege level and just check the Run this program as an administrator and then click apply ok.finished now you open success phpMyadmin. bye
mysql -u root -p
UPDATE mysql.user SET Password=PASSWORD('mypass') WHERE User='root';
Flush the privileges: FLUSH PRIVILEGES;
Exit by typing: Exit
Edited line in the file config.inc.php with the new root password: $cfg['Servers'][$i]['password'] = 'mypass'
be succss
Go to 'config.inc.php'. Write your password over here - $cfg['Servers'][$i]['password'] =''
This process is quite simple in correcting the the error. What is happening is a failure to connect to phpMyAdmin. In order to fix the problem you simply need to provide the correct password to the system phpMyAdmin configuration file located in apps\phpMyadmin\config.ini.php
1. the root should already be set as user
2. Insert the password between ' ' and that it.
If you still have problems then this means that the user name and /or the password need to be updated or inserted into the DB. to do this use the command line tool and do an update.
UPDATE mysql.user SET Password=PASSWORD('Johnny59 or whatever you want to use') WHERE User='root';
Go to config.inc.php, find $cfg['Servers'][$i]['password'] and remove any password provided, i.e change $cfg['Servers'][$i]['password'] = 'password'; with $cfg['Servers'][$i]['password'] = '';
Now you can launch phpMyAdmin
Selecting Users menu from phpMyAdmin, select the root user and click Edit previlidges.
Now scroll down to Change Password area, switch between No Password and Password to provide your new password.
that's it.
I had the same error today. I had installed Djangostack and when I checked my task manager there were two instances of mysqld running. I checked one was for wamp server and the other was for django stack. I ended the one for django stack, restarted all services in wamp server and I was able to access phpmyadmin
after installation i started wamp and i was asked for user and pass which were already set on default (user:admin pass: dots), and that was wrong with a message from your topic. Than, i just entered:
Username: root
Password: (leave it empty)
and it worked for me!!
Go to C:\xampp\phpMyAdmin
Edit the config.inc.php file
Replace $cfg['Servers'][$i]['auth_type'] = 'config'; by
$cfg['Servers'][$i]['auth_type'] = 'cookie';
For now on the PHPMyAdmin will ask you for your password, no more error.
Try the following code:
$cfg['Servers'][$i]['password'] = '';
if you see Password column field as 'No' for the 'root' user in Users Overview page of phpMyAdmin.
with MariaDb, above solutions doesn't works.
Use (exemple below with ubuntu 16.04 and mariadb-server Distrib 10.0.28):
sudo mysql_secure_installation
…
Change the root password? [Y/n]
New password:
I have encountered similar mistakes, and later found that my password is wrong.
For UNIX, try this. It worked for me:
connect MySQL use Navicat Premium with inital root/"password"
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
restart MySQL
First you have to go config.inc.php file then change the following instruction
$cfg['Servers'][$i]['user'] ='';
$cfg['Servers'][$i]['password'] ='';
or
If you arrived here because you can't log into your phpMyAdmin, then try the root password from your Mysql instead of the password you put during phpMyAdmin installation.
Just now I have this situation and I have tried this way which is very easy.
First stop your mysql service using this command:
service mysql stop
and then just again start your mysql service using this command
service mysql start
I hope it may help others... :)
After I updated my MySql, I was getting the same error message.
It turned out that after installing a different version on MySql, inside the my.ini, the port was different. Previous MySql version had port 3306 but the new one have port 3308.
Check your MySql my.ini, if it is different use the port from .ini in your connection.
php artisan serve
this command get the env contents for the first time and if you update .env file need to restart it.
in my case my username and dbname is valid and php artisan migrate worked
but need to cntrl+c , to cancel php artisan serve , and run it again
php artisan serve
Check the name of Environment Variable
Case with me:
I was using sqlalchemy in a python-flask project and got this issue.
IDE used: PyCharm
In my config.py file I had setup SQLALCHEMY_DATABASE_URI as:
SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URI")
Mistake I did (it was a silly mistake 😅)
While setting evironment_variables in PyCharm, I did:
SQLALCHEMY_DATABASE_URI=<my_db_uri>
Solution
I changed the above to:
DATABASE_URI=<my_db_uri>
Namaste 🙏
In the my.ini file in C:\xampp\mysql\bin, add the following line after the [mysqld] command under #Mysql Server:
skip-grant-tables
This should remove the error 1045.
if multiple myslq running on same port no
enter image description here
Right click on wamp and test port 3306
if its wampmysqld64 its correct else change port no and restart server

MySQL said: Documentation #1045 - Access denied for user 'root'#'localhost' (using password: NO)

I installed xampp,but when I tried to run it I got an error as thus:
Error
MySQL said: Documentation
1045 - Access denied for user 'root'#'localhost' (using password: NO)
Connection for controluser as defined in your configuration failed.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
I tried to search on internet for a solution, but I still can't fix my problem. I have already checked whether I used a password or not in config.inc.php file but i have not used any password.Also, when i try to access with a password, I still can't solve this problem.
I hope anyone can help me. .thank you
I had this problem after changing the password for the root user in phpMyAdmin. I know nothing about programming but I solved it by doing the following:
Go to file C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php (I guess you would replace "wamp" with the name of your server if you're not using Wamp Server)
Find the line $cfg['Servers'][$i]['password']='' and change this to
$cfg['Servers'][$i]['password']='NO'
Try opening phpMyAdmin again, and hopefully the message will now read "Access denied for user 'root'#'localhost' (using password: YES)
Now change the password in the above line to 'yourpassword' (whatever you had set it to before)
Try this:
Open config.inc.php file in the phpmyadmin directory
Find line 21: $cfg['Servers'][$i]['password'] = '';
Change it to: $cfg['Servers'][$i]['password'] = 'your_password';
Restart XAMPP
Reference
Go to the file C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php
Find the line $cfg['Servers'][$i]['password']='' and change it to
$cfg['Servers'][$i]['password']='root'
where root is the name of the password you had set in this instance
Hope this helps somebody.
Step one: Go to...
C:\xampp\phpMyAdmin
Step Two: Open the config.inc.php file
Step Three: Locate the following information and change the password.
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'ENTER_YOUR_USER_NAME_HERE';
$cfg['Servers'][$i]['password'] = 'ENTER_YOUR_PASS_HERE';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';
Here's the solution to getting the 1045 Access denied for user 'root'#'localhost' (using password: NO) in phpMyAdmin.
First here's what happens:
The problem occurs when you change over from using phpMyAdmin with no password and mysql with no root password. You change root in mysql to having a root password. You dutifully change phpMyAdmin's config.ini.php file's $cfg['Servers'][$i]['password']='' line to include your password and restart everything you can find, but phpMyAdmin still can't get through.
The reason is that your browser still contains cookies for phpMyAdmin and those cookies reflect not needing a password to access mysql.
The solution:
Clear out the cookies relating to phpMyAdmin. Its browser specific, but in my Firefox, its under Tools > Page Info > Cookies.
You might need to relog in with phpMyAdmin or use the signon.php script (under /examples in my WAMP install).
Try this:
1. xampp/htdocs/xampp/cds.php
change line 4 to: mysql_connect("localhost","root","enter password here");
change line 64 to: if(!mysql_connect("localhost","root","enter password here"))
From here
reset your mysql password on xampp security page.
restart your mysql service and then access the phpmyadmin page using your password. i tried it. this is working fine for me.
I'm using Linux Mint 18.2 of this writing. I had a similar issue; when trying to load myphpadmin, it said: "1045 - Access denied for user 'root'#'localhost' (using password: NO)"
I found the file in the /opt/lampp/phpmyadmin directory. I opened the config.inc.php file with my text editor and typed in the correct password. Saved it, and launched it successfully. Profit!
I was having problems with modifying folders and files, I had to change permission to access all my files in /opt/lampp/ directory. I hope this helps someone in the future.
I'm afraid there's a conflict with the port number(80). Make sure you don't run some software like Skype that use the same port 80
I think to troubleshoot your problem you should try the following:
Check whether the MySQL service is running (Control Panel --> services)
Use a MySQL client like SQLYOG to check whether you are able to connect to MYSQL Server with the username and password you are using in your code.
Just try a sample php program, which fetches the data from table
Ex. http://www.anyexample.com/programming/php/php_mysql_example__display_table_as_html.xml
1045 - Access denied for user 'root'#'localhost' (using password: NO)
solution:
Step 1: Open Location of you wamp/xampp
Step 2: Go to phpmyadmin
Step 3: Open config.inc.php
Step 4: Change the password to the password set for the MySql server and not anything else in this: $cfg['Servers'][$i]['password'] = ''
Step 5: Restart all services /restart wamp/xampp.
I had this problem with a fresh install of wamp and using only default settings without setting any passwords. I found an incorrect default setting and I solved it by the following steps:
Go to C:\wamp\apps\phpmyadmin4.1.14 (Your phpmyadmin version# may differ)
open the file config.inc in a text editor
find the line: $cfg['Servers'][$i]['host'] = '127.0.0.1';
change it to $cfg['Servers'][$i]['host'] = 'localhost';
save the file
restart all services in wamp
The problem seems to be that someone forgot to make the server and host match in the configuration files.
Try resetting your password since it seems it has changed you can reset your password by going to
C:\xampp\mysql
and clicking on the resetroot.bat file
Then change in the php config file the password back to blank and you should have access again
Open the config.inc.php file in the WAMP phpmyadmin directory
Change the line ['Servers'][$i]['password'] = ''
to
$cfg['Servers'][$i]['password'] = 'your_mysql_root_password';
Clear browser cookies
Then Restart all services on WAMP
This worked for me.
NB: the password to use has to be the MySQL password.....
My.ini from the file #password and #bind-address="127.0.0.1" are commented change the password to root and uncomment bind-address="127.0.0.1" and from the file cds.php change the
mysql_connect("localhost", "root", ""); to
mysql_connect("localhost", "root", "root");
Stop the Mysql services and try login again it got logged in.
I had this same problem after I dropped the special PhpMyAdmin controluser account from MySQL.
I had to update the config.inc.php file and replace the entries for 'controluser' and controlpass' with 'user' and 'password'.
So my file ended like this:
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password']='123456';
If you are using XAMPP rather than WAMP, the path you go to is:
C:\xampp\phpMyAdmin\config.inc.php
On OSX
I had same difficult, but a figure out a solucition
open terminal
put 'cd /Applications/XAMPP/xamppfiles'
put 'sudo ./xampp security'
then put your root password and answer the questions
Check your MySQL Port number 3306.
Is there any other MySQL Install in your system on same port ?
If any installation found the change the port number to any number between 3301-3309 (except 3306)
user name : root
password : ' ' (Empty)
try to go to Windows services and stop the MySQL service
go to your wamp server and click on "restart all services".
Refrsch your browser

Can't get access to PHPmyAdmin after setting a root password and using Instant Rails

Wanted to get started with Ruby on Rails so I installed instant rails and set up a mysql password. Problem is now I can't get access to phpmyadmin.
From the rails control panel, when I go to configure >> database (via PhpMyadmin) it opens up phpmyadmin with the message
Error
MySQL said: Documentation
#1045 - Access denied for user 'root'#'localhost' (using password:
NO)
When I used to use XAMPP after setting a password instead of taking me directly within phpmyadmin (as it did without a password) it took me to the login screen instead. With instant rails that's not the case. Anyone had this problem when they first set a mysql password and using the instant rails package?
Edit your phpmyadmin config.inc.php file :
Path For Config Page is wamp\apps\phpmyadmin3.4.5\config.inc.php
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = '**your-root-username**';
$cfg['Servers'][$i]['password'] = '**root-password**';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Check following lines in config.inc.php in phpmyadmin directory
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'yourpassword';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
if your root account dont use any password set 'AllowNoPassword' to 'TRUE'
Try to restart your browser after changing the config file.
Go to this directory "xampp/phpmyadmin" and open config.inc.php file. On a Mac, go to /Applications/XAMPP/xamppfiles/phpmyadmin. Then change and configure the below code with your desired requirements. It worked with me. I installed both MySQL and XAMPP and worked successfully.
$cfg['Servers'][$i]['controluser'] = 'Your Username';
$cfg['Servers'][$i]['controlpass'] = 'Your passwaord';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'Your Username';
$cfg['Servers'][$i]['password'] = 'Your password';
$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
was missing from configuration.
I faced similar problem and found an easy way out.
After changing the password in config.inc.php,
phpmyadmin did not start and message was access denied for user xyz#localhost
Step by step solution:
imp: do not change password directly from config.inc.
in the config.inc.php keep the password blank
$cfg['Servers'][$i]['password'] = '';
this will allow phpmyadmin to open without password.
Under tab USERS click editpriviliges for root->followed by change password.
Now if you again try and open localhost/phpmyadmin, it shows error access denied
Now open config.inc.php and set the same password for user that you set in phpmyadmin
example:
$cfg['Servers'][$i]['password'] = 'xyz#abc';
Now open phpmyadmin and it works!!
I had same problem after i changed password in phpmyadmin. Iam usind xampp and windows. After i changed password in my phpmyadmin showed "access denied" and then after changes descripted below phpmyadmin showed blank page. I tried all advices and combinations given here, but problem still remained. I solved it through "config.inc.php", where i changed these lines
$cfg['Servers'][$i]['password'] = 'new_changed_password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
and then and final key - clear cache in your browser! good luck.
This problem made me crazy.After a full day of wasting time I fixed it. I'm using WAMP.
Password was removed using console.
WAMP was uninstalled.
Computer was restarted.
WAMP was re installed.(Now i was able to open PhpMyadmin correctly)
Then the Password was set using PhpMyadmin privileges.
" $cfg['Servers'][$i]['password'] = ''; " in " C:\wamp\apps\phpmyadmin3.4.5\config.inc.php " was edited like this " $cfg['Servers'][$i]['password'] = 'Password given in PhpMyadmin privileges '; "
Now there was not any problem to open PhpMyadmin even with root password.
This video may helpfull. >> http://www.youtube.com/watch?v=lBvfa1wmlbI
I had this issues. I have fixed by changing phpmyadmin ini files configuration.
As per xampp folder structure I found phpmyadmin configuration file in this location: C:\xampp\phpMyAdmin\config.inc.php
Just changing these line my problem solved.
$cfg['Servers'][$i]['password'] = '';
to
$cfg['Servers'][$i]['password'] = 'password';
Thank You !
Check following lines in config.inc.php in phpmyadmin directory
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'yourpassword';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
The above worked for me.After editing the above file,i restarted the wamp and it was all fine
You have a root account with no password. It would be best to have a look into the conf file located in your phpmyadmin directory and check with the password.
rails-mysql-lost-password
If you are rails developer and you have lost password for mysql :
This answer is in connection with Ruby on Rails framework where this behavior occurred
have mysql with user root and password
bootstrap new rails project
using with mysql "rails new projectname
-d mysql"
do not modify config/database.yml - defaults credentials for server are name: root, password is blank
rake db:create prompt show up - asking for root password and then when you provide root password
the answer is in GRANT command on line 68 in here
basically it executed GRANT command with credentials matches your current database.yml
I have discussed this topic and behavior will improved and it is taken and reported as a bug.
I was looking for an answer but it's really easy to solve...
Open XAMPP App -> Go to General then open Terminal
execute the following command:
mysqladmin --user=root --password=[OLD_PASSWORD] password ""
But how to set a root password? without losing access to to phpmyadmin ?
In case you want to reset password to NULL do following:
Run MySQL Console
It will ask you the password you set. Enter password.
Run following command:
mysql>UPDATE mysql.user
->SET Password=PASSWORD("")
->WHERE User="root";
mysql>FLUSH PRIVILEGES;
You may now access your phpMyAdmin again with PASSWORD not set for root.

Remote mysql connection

I'd been making a web on localhost and when I tried to move it on host it shows me lots of errors. Seems like it can't connect to my local database. Here's the code:
$host = "myip";
$user = "root";
$pass = "";
$db = "mydatabase";
mysql_connect($host, $user, $pass);
mysql_select_db($db);
$on = mysql_fetch_row(mysql_query("SELECT COUNT(online) FROM characters WHERE online=1"));
echo "<br>Online: $on[0]<br><br>";
And here's the output:
Warning: mysql_connect() [function.mysql-connect]: Host 'myip' is not allowed to connect to this MySQL server in * on line 46
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in * on line 48
Online:
Thanks for help
It's a mysql user permission problem. Create a new user with phpmyadmin for example and set it's host to localhost if you connect from localhost, or % if you are connecting from outside.
As Alekc correctly stated, it's a permission problem:
You can do this at the MySQL prompt:
grant all privileges on mydatabase.*
to youruser#'your_ip_address'
identified by 'your_password';
Followed by a:
flush privileges;
And then try to reconnect again. Keep in mind that:
your_ip_adress: it's not the MySQL server's IP address but the IP address you are connecting from (your web server?)
your_password: is the one you must use when establishing the connection on PHP side
Also remember that, even though this solution should work, it's not recommendable granting all privileges to a user that will be used by a web application. You can do the same with fewer permissions.
You can do all this with a nice GUI frontend. I prefer command line.