5

I'm just want to install lamp server + phpmyadmin normally in case of when setting up mysql i get this error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I don't know what this is.
I don't know how to run php code in ubuntu because it's my first deal with linux.

  • What command did you use? How are you installing? What do you want to achieve? You need to give us much more information for us to help you. – Alvar Jan 7 '13 at 15:55
  • i'm just try more than one command and all of it didn't work – amr atef Jan 7 '13 at 16:16
  • and my achieve is wright & running php code with frameworks & cms – amr atef Jan 7 '13 at 16:17
  • 1
    @amratef Take the help of pastebin.com and give us complete log . – rɑːdʒɑ Jan 7 '13 at 16:21
  • so i want to clean all of command and start again – amr atef Jan 7 '13 at 16:22
4

Here's what worked for me:

Just append "sudo" to the beginning of that mysql command:

sudo mysql -uroot -p

Please note the "sudo" at the beginning of that command

| improve this answer | |
  • 1
    You don't need sudo, because you just connecting to a server (MySQL in this case) from some host (localhost in this case), and making an authentication via user (MySQL's root in this case) and its password. More important thing here is the -p argument. – pa4080 Jan 10 '17 at 18:29
  • Believe me, I just tried that on my linuxMint and it worked; I'm trying to install libreNMS and following instructions here: docs.librenms.org/Installation/Installation-Ubuntu-1604-Apache – pelican Jan 10 '17 at 18:43
  • This worked for me, too. Not sure why. – SaintWacko Jan 23 '17 at 16:23
3
  1. Set a password for mysql:

    sudo dpkg-reconfigure mysql-server-5.x
    
  2. Now open the terminal and type:

    mysql -uroot -p
    

Give password and press Enter.

| improve this answer | |
  • It is important to remember that the password must be after -p, without any space. – felipe.zkn Apr 15 '15 at 14:59
  • @felipe.zkn it is better to press enter after -p , so that password won't be displayed in the screen – Tachyons Apr 16 '15 at 9:27
  • Thanks for the warning! As I am on a secure place, I always use the direct form. – felipe.zkn Apr 16 '15 at 11:01
  • If the username and the password (when you enter it through command line) consists of special characters, you can enclose them in single quote marks: mysql -u'ex@mp!e' -p'p@$$wd'. – pa4080 Jan 10 '17 at 18:57
1

I think it is important to note on this older post that MySQL has changed some things in the past 5 years. Digital Ocean states the following in their tutorial called How To Install MySQL on Ubuntu 18.04:

In Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is set to authenticate using the auth_socket plugin by default rather than with a password.

Therefore, run the following to install properly and securely:

sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation

I personally answered y for every prompt from the mysql_secure_installation and created a strong password (option 2, if you set up the VALIDATE PASSWORD plugin). However, the particular choices here are your's to make. Either way, you will set a password under one of these prompts. Although, as you will see, you won't necessarily need the password.

After the prompts for mysql_secure_installation are complete. All you have to do is type the following to log in:

sudo mysql

This is because the native authentication method for MySQL 5.7 and later is auth_socket instead of mysql_native_password for better security. No need for a password, because you can only log in from the machine it's installed on.

If you need to use a password to log in from another source, or want to know more, I recommend reading How To Install MySQL on Ubuntu 18.04 in its entirety.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.