I have 2 different server running django in it. (using postgre)
Both has the same user table.
I wanted to synchronize the user table, as if I update or delete user in one server then the 2 db should also get updated.
I guess replication is not a solution for my case.
Can anyone point me in right directions. or any link or reference will be helpful.
Both server are running different django code.
Thanks,
I don't know how to do this in PostgreSQL, but in MySQL you could create database VIEW pointing to a table in another database. This way you could reuse the existing auth_user table in the other sever.
I would take a look at pgpool-II. I haven't used it myself, but it's been recommended to me for similar purposes and after a bit of research I came to the conclusion that it's one of the better projects out there.
Related
We have our test webserver and main webserver on the same (virtual) webserver with CentOs7. Having them both there is very convenient for us (small company) for several reasons.
We also have the test database and the main database on that same server, also convenient for several reasons.
We created first the main database via directadmin/phpmyadmin, only much later the test database. We use two different logins for phpmyadmin: one that only accesses the main database. For accessing both test db and main db and also system db's we now use the root login, handy to maintain all databases (test and main and others).
We sometimes sync the two databases (mostly data from main to test to be able to test with up-to-date data, and the structure from test to main after testing code and db). Part of the structure we want to copy are some phpmyadmin goodies like the popups with foreign keys. phpmyadmin uses a set of pma__xxx tables for this, like pma__table_info.
Problem is: we have this set of tables now in both databases, both in the test and main database.
And in these tables, we always find records for both databases. For instance, on the test server, there may be records with pma__table_info.db_name set to the main server but also the test server. The same in the main server. Yet the content of the tables is completely different. And I notice that if records are in both pma__table_info tables, the system does not necessarily take the pma__table_info-info from the server that table is on.
I don't understand (also not after google and looking at https://docs.phpmyadmin.net/en/latest/config.html):
Why is there not a separate database for the set of pma__ tables? Why is it in our database(s)?
Why are there two sets pma__ tables, on on each of our databases? Was this just because we made a db copy? But why does phpmyadmin then actually then use records from the copy and not from the original? And why are the tables so different on both db's?
So it seems that the pma tables on both databases are used for both databases. How do I know which set of tables is used when? Does that depend on the phpmyadmin login we use?
Should we merge the pma__ tables into a separate database and tell phpmyadmin via the config to use this separate database? Would that work if we login with a login that only has access to the main database?
Googling gives no basic answers, only technical stuff but I need to know the basic stuff above first before I figure the technical stuff out.
A link to basic pma__ table info (other than technical config info) is also very welcome.
Thank you so much!
So I seem to have find the answers myself in the end. If I am somewhere wrong, please correct.
Because phpmyadmin is configured normally to use the current db. So that it goes well when you only have one database. And handy when you don't have access to the config files.
See above. phpmyadmin will, afaik, use the first db you open after starting phpmyadmin, and will keep using the tables in this db even after you switch.
See 2.
Definitely. Create a user and db for pma, adjust the config file with those, and you're good to go.
I am brand new to MySQL and I am trying to understand how it all fits together. I have a very strong understanding of Microsoft Access, but this is a whole new world.
I create a schema (MySQL Model) and I had no problem creating an ERD. I then figured out how to Reverse Engineer it and add it to the local instance of my server which is Local Instance MySQL56.
But I cannot find the ERD on the local server. I then added more tables on the server, but I want to add the tables to the ERD so that I can relate the tables. But I cannot find any option to add or edit an ERD.
Am I missing something? How do I relate the tables without an ERD?
Thanks,
David
#PM 77-1, thanks for your responses. I am using Workbench for MySQL, which is a GUI.
I did discover the answer to my question by experimenting more with the tool.
While viewing the MySQL Server Instance, select the database that you are working on.
Select the Database Menu and Reverse Engineer...
For me, I just accepted all of the default options as I stepped through the wizard.
Then once I finish making all of the changes, reverse the process by doing a Forward Engineer.
I've searched for an answer to this and all I can seem to find are questions asking whether it is better to use multiple databases or multiple tables in a single database. This isn't my question though.
QUESTION 1.
I want to set up a new database alongside my current DB and don't know how. I want to give a user full admin access to DB2 without seeing DB1. This way I can host a friend's site and they can create and delete as many tables as they want without disturbing my own DB. I could also use it for demo sites that aren't secure and shouldn't exist inside my primary DB.
I figure I could do this pretty easily with a virtual machine and run a separate instance of MySQL but my resources are limited so that isn't really an option.
I'd like to set this up in one of 2 ways. I would prefer to have "server.example.com" host both DBs and open the proper DB based on user login. If not I could do it routing to server1.example.com and server2.example.com.
QUESTION 2.
If this isn't possible I'd like to know how to properly set up restricted access to a single DB in sequel pro. I have been messing around with it and so far prefer it to PHPMyAdmin. For some reason if I set up a new user with no permissions they have full access to my 'information_schema' and 'test' tables but can't create new tables. I don't want other users to access these tables though and I want them to be able to set up their own tables. I'd like to set it up so a new user can create a limited number of tables and only see and edit those tables. I can't seem to find information on this either.
Even if my first question is possible I'd like to know the answer to question 2. I've been searching for a long time and can't find reliable information anywhere. Maybe my brain is just tired...
You can set up multiple instances of mysql but for your situation you are better off creating different databases within the same instance.
You can create databases and then add users that only have access to manipulate the database they are given and nothing else.
Essentially the heirarchy is as follows:
Mysql (root or any other super user can see everything)
- Your DB
- Your Users
- Your tables/functions/Procedures/etc
- Their DB
- Their Users
- Their tables/functions/procedures/etc.
You basically separate the access for each, and in PHPMyAdmin it is very easy. The steps are:
Add Database )
Add User, restricting them to that database allowing only priveleges you want to give to that user and only to that database. (Guide here)
You can grant access to different database to different user using GRANT in MySQL.
https://dev.mysql.com/doc/refman/5.1/en/grant.html has the information you need.
The most simple you can do is
CREATE DATABASE db_for_user_a
CREATE DATABASE db_for_user_b
GRANT ALL PRIVILEGES ON db_for_user_a.* TO user_a IDENTIFIED BY 'user_a_s_password'
GRANT ALL PRIVILEGES ON db_for_user_b.* TO user_a IDENTIFIED BY 'user_b_s_password'
You are going to need to provide more information about your set up to answer this question of setting up multiple databases specifically.
Servers typically have methods to create multiple databases with software that is designed specifically to run on those platforms (Apache, and Windows server are a couple servers that can run software like WAMP or phpMyAdmin to manage these databases).
And in answer to the permissions: Yes, you can designate users that can have specific privileges on one, both, or neither of the databases. But, you can also set up table-specific roles and actions as well. This is more obvious with Microsoft's management studio though, where Mysql you may want to use something like Mysql Workbench initially.
On cPanel, for example, you can add a new database if your host allows it. On windows, you'll have to use other tools to set up a new database.
In answer to your first inquiry, each database requires its own connection, and there are database-wide operations that you can do such as migration and backups. A rule of thumb is to only keep entirely separate data in different databases, unless there is absolutely a reason to separate types of information into a different kind of database for efficiency. Typically, you do not relate data between different databases except for much more complex situations.
You can create separate databases and use them separately in sequel pro, I believe. Most platforms have an option to create a new db in the databases list.
Well I think I was confusing some stuff here. I apologize for that. I was calling databases 'tables'.
I was wanting to allow users to create new databases but not see the ones that others create. I think I can make this work by just limiting permissions and allowing users to access one or two databases.
It seems like PHPMyAdmin has some easier to use options than Sequel Pro. I've only briefly used it in the past but I'll give it another shot.
As for command line stuff, I love being able to work in command line but I don't know all the commands so it makes things generally difficult to figure out and the man pages weren't all that helpful.
Thank you for your answers and I'm sorry for my newbie questions.
I am developing a web application in which a user can Create a table in data base. I am thinking on taking the attribute names and table description from user and put them into SQL query and execute it. But the drawback is that if this application is installed somewhere else all the db connection parameters have to be changed secondly it will be hard coded. Or is this the approach in software industry?
Another approach I can think of is taking all the information about creating a new table from user and inserting them into one table and have some kind of trigger on this table which creates a new table everytime when insertion is performed into the first table.What would be the SQL Script for such thing if my approach is correct?
I am using SPRING - MVC, Hibernate, MySQL, REST web service
Please correct me if I am thinking in wrong direction. TO be honest I am not clear on how I am going to do this.
Thanks
This is risky, since a database schema with a vague and ever-expanding schema will become difficult to manage. Your problem isn't how to manage the credentials, which you would have to handle securely whether users were creating tables or not. Your problem is why it seems necessary for users to create tables.
Are you building an interface to manage arbitrary databases? Maybe phpmyadmin would give your users everything they need.
Or are you doing something not quite so general purpose and open ended? Perhaps with a sufficiently rich table design, you can give the users what they want without requiring that they build their own tables. What information do users have to put in a table that it looks like they need to build their own?
If you are more specific with your objectives, we could be more helpful.
I recently inherited a website and they have a simple back-end area which was created using phpmaker. The back-end displays various MYSQL database tables.
There are two tables which hold registration information related to promotions/contests the company runs online. The client wants to begin archiving the registration data monthly, but still have the data accessible for future export or review.
So, can anyone tell me what the best approach would be to achieve this? I read about partitioning and Maatkit, but I'm not sure which - if either - would be a smart choice.
I would prefer to keep the table names the same because the table name is referenced in several instances within the PHP code running the promo/contest applications. I would also like for everything to be 'automatic' or at least executed at the click of a button; though I realize that might not be completely realistic.
I should note that I do not have the phpmaker project file and have been unable to obtain it.
Any help on this matter would be a great help.
MK-Archiver This is a good way to archive live mysql database tables
What MK- Archiver does is to archive rows from a table to another table and/or a file