简体   繁体   中英

How to add a MySql database and user to another table and user?

Let me explain it to you what actually I'm looking for.

For example: we crated two databases and users in MySql

1. Database Name: Test1 / MySQL User: Test1
2. Database Name: Test2 / MySQL User: Test2

in Datebase and user Test1 , we installed a website template including user registration and login and etc

and in database and user Test2 , we installed ticketing system

  • If an user will register an account in website, his username and password will store in table pt_account in Test1 database test
  • If an user will register an account in ticketing system, his username and password will store in table ticket_account in Test2 database test

Here is my question:

How to connect these two tables pt_account and ticket_account to each other, I mean user will be able to login into ticketing system and submit ticket with his/her username and password that he registered in website, no need to register account for ticketing system.

Is it possible to do like this?

It's possible to do! but its better to create an api on website and use that for login in another project instead of duplicate username and password.

you can create a Webservice for Check Username and password and Simply call it with other websites and applications. in this case, last status of users already exists and for future items, simply add a method to this webservice, for example, change password or etc.

You can use views to achieve this if databases are hosted on same MySQL instance. If table structure is same, it is very simple:

CREATE VIEW Test2.ticket_account AS SELECT * FROM Test1.pt_account

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM