I Installed MySQL server (MariaDB 8.0) on my CentOS 7 using yum. Once started the service and when I tried connecting to the database, I got the below error:
MySQL version is as below:
Access Denied For User Root Localhost Mysql
I am using MySQL from within a virtual machine, and the hostname is appended to the login string automatically. For example: mysql -user=johndoe -host abc.com gives: ERROR 1045 (28000): Access denied for user 'johndoe'@'ubuntu.mydomain.com' I need to be able to change this so it reads: 'johndoe'@'mydomain.com'.
Why do I get access denied error after MySQL installation?
- Before, I have researched many questions related to my problem at Stackoverflow, but none of these questions answers solved my problems. The following questions: Initial authorization issue in mysql.
- Mysql: Access denied for user 'root'@'localhost' right after installation on macOS. Start MySQL server from command line on Mac OS Lion.
- In a terminal window stop MySQL (or use control panel) sudo /usr/local/mysql/support-files/mysql.server stop 2. Start the MySQL without privilege tables sudo mysqldsafe -skip-grant-tables 3. IN ANOTHER COMMAND WINDOW start the mysql client mysql 4. Find name of admin user (probably 'root'), update the password.
Generally, after installing MySQL the UNIX users will be able to access the database immediately without entering the password. But starting from MySQL version 5.7 and above, the password is set for root user automatically and stored in the error log file. To know the password, run the below command:
Copy the password from the error log and use it to login to MySQL.
Change the MySQL root password
After your first login to the database, remember to change the root password immediately as shown below.
Also, learn to recover lost MySQL password here.
Updated on November 2, 2018Tagged: MySQL