I have just installed mySQL on my Mac. The install appears to have been successful. I can successfully start and stop mySQL from the terminal command line. While in python I am attempting to create a connection and a cursor but am getting the following error message:
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
My code to get to this point is very simple:
import mysql.connector
cnx = mysql.connector.connect(user = 'root')
the import statement executes without error but the command to create the connection gives the previously stated error. I have gone through all the internet questions I could find about this topic and none of them had a solution for me. Could this be a password issue. When I installed SQL I was given a password that during the SQL install process I was told I would be prompted for but I have not been prompted for the password. I tried to include the password as part of the connection configure parameters but that just gave the following error message:
cnx = mysql.connector.connect(user = 'root', password = 'supplied_pass')
mysql.connector.errors.DatabaseError: 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
Any help on solving this would be appreciated.
I found the solution. After the SQL install it was necessary to perform a secure installation where I reset the password and eliminated the anonymous user. The password reset and anonymous user elimination occurred by following the prompts from the secure install. The original install was in the /usr/local/mysql/ directory. So at the terminal prompt I did a change directory to the /usr/local/mysql/ directory (cd /usr/local/mysql/bin/). Once in the new directory I typed this command at the terminal prompt: sudo ./mysql_secure_installation . At that point I just followed all the prompts to change the password and eliminate the anonymous user. Once that was complete I was able to successfully create a SQL connection and cursor.
Related
I have installed Xampp on windows 10 to create a simple app to understand how to use Laravel. I have the last version of Xampp. I configure PHP correctly (with path and so on), but I have a problem with MySQL.
I put the MySQL bin folder address in the user variables path (section in the system properties). In this way, my prompt command recognizes the mysql command. The problem arrives when I write this command: mysql -v. I tried a lot of things, but this Error remains:
ERROR 1045 (28000): Access denied for user 'personalUser'#'localhost' (using password: NO)
PS: personalUser is a generic name to indicate the name of my user.
I have tried to substitute the MariaDB with MySQL in the Xampp folder (I don't know why Xampp has the MariaDB version instead of MySQL). I redownload Xampp twice times. In the xampp folder, in the phpMyAdmin folder, in the file config.inc.php, I changed this command line:
$cfg['Servers'][$i]['password'] = ''; with $cfg['Servers'][$i]['password'] = 'NO';
I tried other things.
Based on the error message you are receiving, it seems that the issue is related to the authentication credentials for the MySQL server. The error message indicates that the user 'personalUser' is not allowed to access the MySQL server because they are not using a password.
To fix this issue, you can try the following steps:
Open the MySQL command-line client by running the mysql command in your terminal or command prompt.
When prompted for a password, enter the password for the user 'personalUser'.
If you do not know the password, you may need to reset it by following the steps in this MySQL documentation: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
Once you have successfully authenticated with the MySQL server, you can use the GRANT command to grant the 'personalUser' user access to the database you want to use. For example, to grant access to the 'mydatabase' database, you can use the following command:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'personalUser'#'localhost';
After granting the appropriate privileges to the user, you should be able to access the MySQL server and use it with Laravel.
If you continue to have issues, you may need to check the configuration of the MySQL server to make sure that it is set up to allow access from the user 'personalUser'. You can refer to the MySQL documentation for more information on how to configure user access: https://dev.mysql.com/doc/refman/8.0/en/adding-users.html
I'm setting up a MySQL database following this tutorial. I installed it and successfully initialized an instance with a root password, but I am having trouble connecting to the instance via command line. When I click on the 'mysql' executable under bin, I get this message
ERROR 1045 (28000): Access denied for user 'hunter'#'localhost' (using password: NO)
and if I try to enter
> mysql -u root -p
in the terminal I get this message
-bash: mysql: Permission denied
It says in the instructions that I should be getting prompted to enter the password for the database, but for some reason it won't let me.
I would suggest first off to try a mysql workbench. You can download it at https://dev.mysql.com/downloads/workbench/ .
It seems that calling mysql from bash is causing issues for you. If you are using a *Nix environment, it could be a permissions issue and you need to set the correct permissions on the mysql binary. However, usually a correct installation should have already done that. See: https://askubuntu.com/questions/229589/how-to-make-a-file-e-g-a-sh-script-executable-so-it-can-be-run-from-a-termi
Secondly, you should use the username root . hunter is not default username.
From the mysql documentation:
How to Reset the Root Password
If you have never assigned a root password for MySQL, the server does not require a password at all for connecting as root. However, this is insecure. For instructions on assigning a password, see Section 2.10.4, “Securing the Initial MySQL Account”.
Reference:
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
I'm a beginner with linux (linux mint distro) and I have been trying to install mysql server and workbench. I couldn't connect to mysql server without sudo command. I tried to connect to the server on workbench, and Access denied for user 'root'#'localhost'. So I try to run workbench with sudo from terminal. Nothing. So I followed what somebody posted here on stackoverflow about changing my password auth mode to mysql_native_password, and was able to access SQL Server from workbench (only using sudo command).
So I try to import a dump which I made on windows mysql-workbench, and it gives me two errors:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
and
ERROR 1115 (42000) at line 24: Unknown character set: 'utf8_general_ci'
Nevertheless, the database seems to have been correctly imported (I can see values and columns and tables and they look alright).
What's happening and how to stop getting these access denied errors? I tried to search the web and there are different answers, but none of them seem to address first install. I don't see why wouldn't it work if I have made a pretty default install :(
Thanks a lot!
ps: I don't know if more specific info is needed. anonymous user was dropped after installation
Try resetting root password.
Step 1. Access to mysql using mysql -uroot
Step 2. Check the root user
select Host, User, authentication_string from mysql.user;
Step 3. Change password for root user
use mysql;
update user set authentication_string=password('NEWPASSWORD') where user='root';
flush privileges;
quit;
Now try accessing to mysql using mysql -uroot -p using new password. If it works, use the credentials in workbench.
I have spent many hours reading and trying dozens of variations of ways to reset the root password, but I am not getting anywhere. The most complete set of instructions I found (and tried) were the following. BTW, I am running MySQL 5.5 on Win7, 32 bit.
I created a file, c:\mysqlinit.txt, containing the two lines:
UPDATE mysql.user SET Password=PASSWORD('myroot') WHERE User='root';
flush privileges;
Stopped the MySQL55 Service from Control Panel, Admin Tools, Services
Opened a Command prompt window (running as the admin)
Navigated to \Program Files\MySQL\MySQL Server 5.5\bin\
Executed the command
start mysqld --init-file=C:\mysqlinit.txt
Everything seemed to work fine (no errors). At the completion of this procedure, I thought I could log on with the root user name and the above password, but when I executed the command
mysql -u root
I received the error message,
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
I am probably doing something wrong, but can't spot it and it is driving me nuts.
A can reset password in windows with this steps:
1) Stop running Mysql service first (Administrative tools > Services )
2) "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" -u root --skip-grant-tables
3) uninstall mysql server
4) install mysql server and set in installation:
root current password - it's must be blank
new password - set your new passowrd
confirmation new password - set your new passowrd
also there I added new admin user konst
I have a VPS running CentOS and have apache, php, mysql all installed. I was following a tutorial for installation and apparently did something wrong when setting up mysql (I believe something with setting user and password). Now whenever I try to get to the MySQL command line interface I receive this error.
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I looked this up and got a few suggestions to try to bypass so I can reset the passwords. I've tried:
/etc/init.d/mysqld --skip-grant-tables
Which came up with the same error. I tried reinstalling by first removing mysql and then installing it again. Same Error appears. What else can I do?
(if U don't have anything in DB, remove mysqlDB - not installation, but DB files in /var/lib/mysql/ - backup it first!)
start this: shell# mysql_secure_installation
it will ask U to:
Set a root password. If you already have it
you’ll need to enter it for the remaining steps.
Remove anonymous users
Disable non-local root access
Remove the test database and access rules related to it
Reload privilege tables so the above changes are in effect
BR