So I have mySQL installed on Ubuntu and I'm trying to access it with PHP.
As long as I'm in Ubuntu, I can access mySQL from the command line without any issues. However, with PHP, I can only connect to mySQL. Once in, though, it refuses to let me select a database. I've enabled all permissions to the user alias that I'm connecting with, and even allowed remote access to the database.
As root, PHP shows the following error:
(1049) Unknown database 'my_database'
As the user alias I use (called 'default'), PHP shows a different error:
(1044) Access denied for user 'default'#'localhost' to database 'my_database'
What am I missing? This never happened until I upgraded to Ubuntu 10.11.
Grant your user privileges to that database with the correct password:
GRANT ALL PRIVILEGES ON my_database.* TO default#localhost IDENTIFIED BY 'thepassword'
Related
I'm currently making a simple app using Laravel and Xampp. While trying to connect the database and make migrations I got this error message from php artisan:
PHP error
So I decided to configure the database manually from the MySQL MariaDB shell (having started the session as the root user), but regardless of what user I try to gran privileges to on any database I get the following error:
MariaDB error
The only possible reason I can come up with is the fact that there seems to be two different root user listed, but I don't thisnk this is the root of the problem, since I'm starting the shell as root, and not choosing one of these after starting.
User List
I've already triple-checked my root user password (I've been starting the shell with this command mysql -u root -p -h 127.0.0.1). Trying to do this through the PHP MyAdmin interface yields the same error.
I'd appreciate any insights, thank you!
The multiple entries for 'root' are specifying which host addresses are allowed connections from (127.0.0.1 and % respectively)
Your error appears to be because your configured database connection (in Laravel) is using the user 'usario'. Search your files for where usario is defined and input the proper credentials to connect to your database in its place.
This is a common error when credentias supplied to MySQL/MariaDB are simply invalid. Bad username, bad password, or both. In this instance it looks as though you're trying to run a migration with a user that doesn't exist.
I want to build a website on Ubuntu 14.
I have apache, PHP and Mysql installed on it.
I'm using PHP to connect to Mysql but got the error information as follows:
Connection Failed: SQLSTATE[28000][1045] Access denied for user 'root'#'localhost'
Anyone know how to fix it?
Probabbly Wrong Password issue or you didn't set the password for root yet. Try login from terminal using mysql -u root -p and it will asking your current root password.
If you are running a website, do not using root access for your website user access. Create an account with access to specified database.
at first Mysql had no problem ( can access db via mySql command line with my password) but when i run my php file with wamp server ,i receive this Error :
Access denied for user 'root'#'localhost' (using password: YES)"
.... and after that , not only that my php file raise an error , i get an access denied error trying to access my databases with mySql shell .
i ran these php file with xamp and had no problem , but after switching to wamp all these errors appear , any ideas ?
You need to set a new root password within your WAMP environment. It has a different instance of MySQL to the one in XAMPP, so it won't pick up the same root password. Change the root password and try connecting again, that should work.
I'm trying to simply run php artisan migrate --seed on a new Laravel project but everytime I try, I get the error:
SQLSTATE[HY000] [1045] Access denied for user 'appuser'#'localhost' (using password: YES)
I check my database config file and the correct username and password for the database are there.
I check MySQL Workbench, and the correct user is there with all the schema privileges for the same password.
I tried adding the user with privileges under %, localhost and 127.0.0.1 but same access denied error.
I ran a quick check to make sure Laravel was selecting the right environment for the database connection details and it is.
I've created users hundreds of times and never had this problem. This all started after I updated to the latest MySQL Workbench 6.1.7 after the older version stopped working correctly on Windows 8. Sadly, I don't have the option to even go back and test if the old version fixes the problem since it won't work at all.
At this point I can't get any new database users to connect.
The database server is up and running, and every other previously existing user still connects just fine.
Here is the my.ini file.
Any ideas? I'm hoping I'm just tired and missing something obvious here.
by reading the config file.
[client]
password = mysql
port = 3306
socket = "{$path}/mysql/mysql.sock"
i think you need to comment the string with default password. Probaby it affects something.
I have recent MariaDB, and the password string is commented out in every config file example
I just upgraded my developement box's PHP to the latest version, 5.4.5. This developement machine connects to a remote MySQL server, residing on a shared server that I lease from a hosting company.
Trying to connect to my remote MySQL server using simple mysql_connect('myserver.com', 'user', 'password') results in the following error:
Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in file.php on line 2
Simply, as advised, just executing:
SET PASSWORD = PASSWORD('my-password');
wouldn't change anything.
The same applies when executing
SET SESSION old_passwords=FALSE;
After a bit of searching, I realized that I needed quite deep access to the MySQL server to be able to fix this problem, which I do not have. Trying to execute this query:
UPDATE mysql.user SET Password=PASSWORD('my-password')
WHERE User='my_user' AND Host='my-server';
FLUSH PRIVILEGES;
Simply gives me the following error:
1142 - UPDATE command denied to user 'u0112918'#'www10.aname.net' for table 'user'
Requests to have the company execute the query for me has, so far, been unsuccessfull. So my question is if there's any way to fix this on the client side, without involving the MySQL server?
Hm, try executing the following query through a tool other then PhpMyAdmin, such as Mysql Workbench or through a shell:
SET SESSION old_passwords=0;
SET PASSWORD = PASSWORD('passwordString');
You should be allowed to change your own password without DML Rights on user-table.
Edit: since it did not resolve the issue - when "read_only" is enabled for the database then you need super rights to change (even your own) password ( http://dev.mysql.com/doc/refman/5.5/en/set-password.html )