I installed MySQl-server in Linux. But I can't use it as normal user (local). I have to use it as root user. I have tried fixing by using $ sudo chown -R sura:sura /usr/bin/mysql, however I still can't use MySql as normal user. This is error I always get when typing $ mysql in the non-root terminal,

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

To use in the non-root terminal, I have to put sudo and follow by mysql, this can make me use MySql without root.

Do you have anything that can fix this issue? Or do I have to continue using MySql as root user?

If so, could you please tell me the way to fix?

  • 3
    There is nothing to fix: you tried to ue sura without a password. You probably set a password for sura and need to add the -p option and then supply the mysqlpassword for sura. If you ever have made that user in mysql that is.. And why do you assume you need to mess with permissions? There are -NO- instructions on you needing to alter permissions for mysql. so why do that?
    – Rinzwind
    Jun 10, 2018 at 13:24
  • @Rinzwind So, how can I uninstall MySql completely so that I can reinstall MySQL. Could you please tell me? I have tried uninstalling before, but when reinstalling, it was not the same as the first time I installed.
    – Liu Bei
    Jun 10, 2018 at 13:34
  • No need to uninstall/reinstall mysql. Just undo your chown by issuing sudo chown root:root /usr/bin/mysql and then follow the steps in the answer below.
    – PerlDuck
    Jun 10, 2018 at 14:56

1 Answer 1


From this tutorial you need to create a database and user to use mySQL.

To create a MySQL database and user, follow these steps

At the command line, log in to MySQL as the root user:

mysql -u root -p

Type the MySQL root password, and then press Enter.

To create a database user, type the following command. Replace username with the user you want to create, and replace password with the user's password:

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';

This command grants the user all permissions. However, you can grant specific permissions to maintain precise control over database access. For example, to explicitly grant the SELECT permission, you would use the following command:

GRANT SELECT ON *.* TO 'username'@'localhost';

For more information about setting MySQL database permissions, please visit MySQL - GRANT Statement.

Type \q to exit the mysql program.

To log in to MySQL as the user you just created, type the following command. Replace username with the name of the user you created above:

mysql -u username -p

Type the user's password, and then press Enter.

To create a database, type the following command. Replace dbname with the name of the database that you want to create:


To work with the new database, type the following command. Replace dbname with the name of the database you created above:

USE dbname;

You can now work with the database. For example, the following commands demonstrate how to create a basic table named example, and how to insert some data into it:

CREATE TABLE example ( id smallint unsigned not null auto_increment, name varchar(20) not null, constraint pk_example primary key (id) );
INSERT INTO example ( id, name ) VALUES ( null, 'Sample data' );

Much more can be found in the tutorial linked above such as:

  • Creating SQL scripts
  • Deleting tables and databases
  • View a list of all users

More Information

To view the official MySQL documentation, please visit MySQL 8.0 Reference Manual.

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.