0

install on Ubuntu 16.04 LTE Xampp (lampp) all good It Works:

# ~ $ Sudo / opt / lampp / lampp status
Version: XAMPP for Linux 5.6.20-0
Apache is running.
MySQL is running.
ProFTPD is running.

But when I want to enter the TERMINAL has mysql:

#:~$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
#~$ sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
#~$ sudo mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I have not defined a password, I entered as password: password

Can you help me ?

Piotr
  • 21
  • 1
  • 4

4 Answers4

1

Try: mysql -u root -p

It will ask password next line

Dipanwita Kundu
  • 1,637
  • 1
  • 9
  • 14
  • i have never create password – Piotr Sep 30 '16 at 08:28
  • when you type 'mysql -u root -p' it will ask "enter password" just hit 'enter' key.It will goes to mysql cmd prompt. Do you want to set password? – Dipanwita Kundu Sep 30 '16 at 08:33
  • i want use mysql, just because if i use workbench for use database i need enter a password ans i enter 'password' and i can use database – Piotr Sep 30 '16 at 09:14
  • To set password, please check this link: http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html – Dipanwita Kundu Sep 30 '16 at 09:16
  • Ok thx, just for the moment i have rm xampp and i download, install a last version : wget https://www.apachefriends.org/xampp-files/7.0.9/xampp-linux-x64-7.0.9-1-installer.run may be, the fact of installing xampp settle the problem – Piotr Sep 30 '16 at 09:21
0

i do that:

sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;

mysql> select * from user \G
*************************** 1. row ***************************
                  Host: localhost
                  User: admin
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: Y
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
 Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
              ssl_type: 
            ssl_cipher: 
           x509_issuer: 
          x509_subject: 
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: auth_socket
 authentication_string: 
      password_expired: N
 password_last_changed: 2016-04-27 20:49:21
     password_lifetime: NULL
        account_locked: N
*************************** 2. row ***************************
                  Host: localhost
                  User: mysql.sys
           Select_priv: N
           Insert_priv: N
           Update_priv: N
           Delete_priv: N
           Create_priv: N
             Drop_priv: N
           Reload_priv: N
         Shutdown_priv: N
          Process_priv: N
             File_priv: N
            Grant_priv: N
       References_priv: N
            Index_priv: N
            Alter_priv: N
          Show_db_priv: N
            Super_priv: N
 Create_tmp_table_priv: N
      Lock_tables_priv: N
          Execute_priv: N
       Repl_slave_priv: N
      Repl_client_priv: N
      Create_view_priv: N
        Show_view_priv: N
   Create_routine_priv: N
    Alter_routine_priv: N
      Create_user_priv: N
            Event_priv: N
          Trigger_priv: N
Create_tablespace_priv: N
              ssl_type: 
            ssl_cipher: 
           x509_issuer: 
          x509_subject: 
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
      password_expired: N
 password_last_changed: 2016-09-14 09:06:40
     password_lifetime: NULL
        account_locked: Y
*************************** 3. row ***************************
                  Host: localhost
                  User: debian-sys-maint
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: Y
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
 Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
              ssl_type: 
            ssl_cipher: 
           x509_issuer: 
          x509_subject: 
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: *5AE72AD4B851F8C8C59B1A81B9441D6F274D066B
      password_expired: N
 password_last_changed: 2016-04-27 00:23:17
     password_lifetime: NULL
        account_locked: N
*************************** 4. row ***************************
                  Host: localhost
                  User: phpmyadmin
           Select_priv: N
           Insert_priv: N
           Update_priv: N
           Delete_priv: N
           Create_priv: N
             Drop_priv: N
           Reload_priv: N
         Shutdown_priv: N
          Process_priv: N
             File_priv: N
            Grant_priv: N
       References_priv: N
            Index_priv: N
            Alter_priv: N
          Show_db_priv: N
            Super_priv: N
 Create_tmp_table_priv: N
      Lock_tables_priv: N
          Execute_priv: N
       Repl_slave_priv: N
      Repl_client_priv: N
      Create_view_priv: N
        Show_view_priv: N
   Create_routine_priv: N
    Alter_routine_priv: N
      Create_user_priv: N
            Event_priv: N
          Trigger_priv: N
Create_tablespace_priv: N
              ssl_type: 
            ssl_cipher: 
           x509_issuer: 
          x509_subject: 
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: 
      password_expired: N
 password_last_changed: 2016-04-27 18:11:46
     password_lifetime: NULL
        account_locked: N
4 rows in set (0,00 sec)

if I want to do this :

mysql> update user set password=PASSWORD("newpw") where User='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> flush privileges;
Query OK, 0 rows affected (0,00 sec)

the instructions I found on a forum :

sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set password=PASSWORD("newpw") where User='root';
flush privileges;
quit
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

https://ubuntuforums.org/showthread.php?t=2325339

OR I can for example delete the mysql totally, then I reinstall the terminal? and after uplode my database.sql

Piotr
  • 21
  • 1
  • 4
0

The default root password is blank (i.e. empty) not root. So you can just log in as:

mysql -u root

You should obviously change your root password after installation

mysqladmin -u root password [newpassword]
Kaushik
  • 2,072
  • 1
  • 23
  • 31
  • mysql> mysqladmin -u root password masteradmin; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqladmin -u root password masteradmin' at line 1 mysql> mysqladmin -u root password [masteradmin]; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqladmin -u root password [masteradmin]' at line 1 – Piotr Sep 30 '16 at 08:25
0

My MySQL also had the same starting problem, it doesn't let me logging. So I used:

mysqladmin.exe -u root password <newpassword>

Than it worked! So I went to the file config.inc.php and changed to the new password, I've just set, and restarted my xampp panel. So I used the command:

mysql -u root -p

And typed my new password and worked!