How to log in into MySQL as a different user?

后端 未结 2 909
温柔的废话
温柔的废话 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;
    

提交回复
热议问题