I have followed all the steps of the LAMP installation tutorial in ubuntu 20.04 and even mysql is all enabled with flush privileges I don’t understand why I get this error mysqli_real_connect(): (HY000/1698): Access denied for user ‘root’@’ localhost’
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
If you’ve used the mysql_secure_installation then you’ll need to use a password when connecting to your root user.
- mysql -u root -p
This will ask you for the root MySQL password. Once you give it, you’ll enter.
If you don’t want to use a password for MySQL when you are root, you can create a file in /root/.my.cnf and add the following:
- [mysql]
- user=root
- password=RootPasswordHere
where RootPasswordHere is your actual password.
Alternatively, if you still haven’t run mysql_secure_installation:
You need to change the authentication parameters, to do so just run this command first.
$ sudo mysql
Then run This ALTER Query to change the authentication parameters.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';
And now, you are able to run mysql_secure_installation command.
$ sudo mysql_secure_installation
Hope that solve your issue,
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.