How to log in into MySQL as a different user?

后端 未结 2 910
温柔的废话
温柔的废话 2021-01-25 01:25

Could anyone help me please? I wolud like to know how to change user in MySql. That is, I created another user besides the default user root but i want to be logged in to the us

相关标签:
2条回答
  • 2021-01-25 01:46

    you can create different user and add different privileges to user as below:

    CREATE USER 'username'@'%' IDENTIFIED BY
    PASSWORD '*AAB3E285149C0135D51A520E1940DD3263DC008C';
    
    GRANT SELECT ON database_name.table_name TO 'username'@'%';
    

    And use below command to log in:

    mysql -uusername -ppassword databasename;
    
    0 讨论(0)
  • 2021-01-25 01:57

    In command prompt

    mysql -h host -u username -p

    Form mysql documentation:

    shell> mysql --user=user_name --password=your_password db_name

    Then type an SQL statement, end it with “;”, \g, or \G and press Enter.

    0 讨论(0)
提交回复
热议问题