How do I set the default schema for a user in MySQL

后端 未结 2 1024
醉话见心
醉话见心 2020-12-28 12:02

Is there a way to set a default schema for each user in MySQL and if so how? Where user x would default to schema y and user z would default to schema a.

2条回答
  •  一生所求
    2020-12-28 12:33

    If your user has a local folder e.g. Linux, in your users home folder you could create a .my.cnf file and provide the credentials to access the server there. for example:-

    [client]
    host=localhost
    user=yourusername
    password=yourpassword or exclude to force entry
    database=mygotodb
    

    Mysql would then open this file for each user account read the credentials and open the selected database.

    Not sure on Windows, I upgraded from Windows because I needed the whole house not just the windows (aka Linux) a while back.

提交回复
热议问题