Can't create new entries in DB - php

I am currently running 2 websites that share the same source code, changing only the DB and some minor aspects.
I recently launched my 2nd website and although everything appears to be running just fine I realized that I can't add new entries in the DB. It just gives me the message that the entry already exists, which is not true since there is only a few entries and I am obviously testing using unique entries. Another thing that I noticed is that the data that exists in the DB (I used an internal server to test things out) can be edited, which I assume that UPDATE statement is working but not INSERT INTO and DELETE. It appears that there is some problem with the connection/permission to add/delete new entries, while updating is fine.
All this is very strange as the code (PHP and JS) is exactly the same between websites and the only thing that changes is the VM I used for each of them, which makes me believe that the issue is somehow in the configuration of the webserver. I have replicated all the configurations from the other website, so I am not sure if I am missing something. Here's a list of all the configuration I have implemented:
edited 000-default.conf (of Apache to set the new document root)
changed the ownership of my app to www-data
created a user group with myself in it and changed the group of all subdirectories/files to this group
opened up the port 3306 for mysql
I honestly can't understand what is wrong, I am clearly missing some configuration setting but I have no clue what it might be. One thing that is different is the MySQL version between websites. The website that works is running this version:
5.7.26 MySQL Community Server (GPL)
While my new website is running this:
5.7.19-0ubuntu0.16.04.1 (Ubuntu)
Could this be an issue?
Any help would be appreciated.
Thank you.

Related

Accidentally uninstalled mysql on AWS EC2 with wordpress multisite. Need a little guidance

I have a wordpress multisite installation running on an AWS EC2 (t2.medium).
After messing around trying to get phpmyadmin installed on the server I accidentally deleted httpd,mysql-server etc. It broke everything.
Thankfully, I used a plugin called Snapshot from wpmu-dev and had everything backed up but now I'm running into some trouble and not entirely sure how to do this.
Current situation:
1. Created an instance snapshot through my aws dashboard.
2. Backed up everything from /var/www/html/ to my local drive.
3. Reinstalled mysql and httpd, started it, went through the steps provided here - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html - however, when setting up the database it states that wordpress-db and the user are already there and my old password still works yet wordpress isn't working?
So I'm not sure where to go from here, shall I just delete my instance and start again from scratch? Loading what I need back into the /var/www/html folder? Or is there a way that I can completely delete my database and then rebuild the tables with the snapshot and get back to where I started?
Thanks in advance for your help folks, really stuck here, have a website that's down!
If you are not sure what happened I would recommend you start from scratch.
Launch an EC2 instance and follow the steps on the guide you provided:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html
Download MySQL workbench and connect to the database (remember
modifying the security permissions temporarily
to be able to connect to the database from your computer) (https://dev.mysql.com/downloads/workbench/)
Restore the sql backup (if you have one, or create one if you don't) to restore the database to your new ec2 instance MySQL. You can do this following the Data import section: https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html
Make sure the configuration file is correct (url, database path, name, etc) (https://codex.wordpress.org/Editing_wp-config.php)
I would recommend to point your domain to your new ec2 instance only after it has been properly configured and tested.

Can connect to database on server but cannot insert. Works on mamp localhost

I created a website which was fully functional on my computer's MAMP. When I placed it on the server, everything works well except for the fact that I cannot insert a new user into the DB. I'm partially concerned that the SSL cert is interrupting it, but I don't know enough about this to determine that. To troubleshoot this I did the following:
1. confirmed the connection works by returning row numbers and data that I manually placed into the database
2. confirmed openSSL is active/on
3. confirmed proper placement of my ssl certs through a separate site that confirms their presence
4. checked the error log on the server (which showed no errors) and then created a script to cause an error as proof of principle it works
5.confirmed the phpmyadmin user has full privledges
6. I have two user types and scripts that both don't work that worked on MAMP so I'm fairly confident its not poor coding
Further, all my php sql statements have built in mysqli_error($conn) which show no errors, and when I attempted a basic
"INSERT INTO users (name) VALUES ('john')"
scenario, it was unsuccessful.
My feeling that it is the ssl stems from the fact that my other (non-encrypted) sites don't have this problem. Is there something basic I'm missing?
Its not the SSL, its your configuration. See into it. If you can insert while doing it in the phpmyadmin with a raw sql, then check your config like the hostname user and db name. What server you are using?

Moving a Local mySQL database from Laravel/Homestead to live site database

I'm new here so sorry if this is posted in the wrong place >.<
I recently started using CraftCMS and decided to make a site with it. After looking at multiple forums about development I decided to use Laravel/Homestead to develop the site locally. It's working great! Everything is working fine, all the data is being saved and it works every time I boot up homestead.
The one question I have is how to move all this data from my local database to a live site. I have Bluehost and I know it's capable of mySQL and hosting a CraftCMS site. I just need to know how to transfer all the data.
I've been using Sequel Pro to monitor everything locally. So I feel like it's possible. Not really experienced with databases in this way. Just need a nudge in the right direction. Thanks!
Can you access to your Bluehost DB in Sequel Pro? If you can, I think you should first go to your local homestead DB and click [File]->[Export]. And go to Bluehost DB and click [File]->[Import]. Remember to choose the same format as you exported.
It's definitely possible.
If you can export your craft db with sequel pro (or the command line)
Assuming your local database env is root with
mysqldump -u root -p password mycraftdb > dump.sql
You'll need to import this sql file in phpmyadmin on bluehost
Here's a help doc. https://my.bluehost.com/hosting/help/256
Start a new database unless you're using the old tables in your new local craft site. Definitely back up your old one.
Whenever you work with a host like Bluehost, godaddy, etc. You're going to have an obnoxious time trying to get everything configured to pass the system report for craftcms. Sometimes you'll even have to reach out to the host to do something simple like upping a memory_limit.
Here's an article my friend wrote about his experiences using craftcms with these hosting environments. It could be helpful.
https://medium.com/#importantcoding/craftcms-how-i-hate-to-love-you-e0d26722a1d2

How to debug wordpress admin user search in MAMP

I'm developing my Wordpress site locally on OSX 10.8 using MAMP Pro v2.2.1. Everything works normally EXCEPT for when I'm logged in as an admin user and I go to Settings > All Users and then try to search for a specific user (using the search bar at the top). Whenever I do this, the form seems to submit, the little spinner on the browser starts turning... and then nothing happens. No errors in the console. No 500 page. Just spinning wheel forever. And after that I can't open any of the other menus unless I stop/start MAMP. I have a lot of experience debugging wordpress plugins and themes, but I have no idea how to debug admin stuff since it's provided by the core.
What I've tried so far:
All other menu pages respond normally (unless I cause this crash).
All other admin menus respond normally, including search functionality.
The live site works fine on the server, including user search
My colleague does not have this problem when checking out the same code and testing on his PC with XAMP.
I ran CHECK TABLE wp_users and MySQL returned "Ok"
I checked MAMP's php_error.log, mysql_error_log.err
Another detail is that after I trigger the problem (by searching users), I can close the window, browse to other websites, and when I return to my local site it's STILL broken. The only way to resolve it is to restart MAMP
I would love any suggestions for how to debug this problem because I'm in the middle of a project that involves user registration and the inability to search users is really inconvenient.
Have you set up a local database to use, or is your MAMP copy of the site connecting to the live database? Remote database connections are often slow and may time out if you're opening and closing connections quite often (or not closing them all).
I was able to solve this by deleting a bunch of users from the wp_users table. I suspected that I was only having this problem in the users table because that was by far the largest table (it had recently been dumped from the production site with around 9000 users). I guess MAMP's MySQL was crashing because it couldn't handle the search query on such a large table. As soon as I removed most of the rows the search started working normally again. I'm sure there's another solution for someone more familiar with MySQL configuration in MAMP.

Connecting to SQL Server very slow

I have a standard php app that uses SQL Server as the back-end database. There is a serious delay in response for each page I access. This is my development server, so its not an issue with the live setup, but it is really annoying for working on the system.
I have a 5 - 8 second delay on each page.
I am running SqlServer 2000 Developer Edition on a Virtual Machine (Virtual PC).
I have installed SqlServer on my development machine but get the same delay.
I have isolated the issue to the call to mssql_connect (calling mssql_pconnect has no effect)
It is a networking issue on how I have set up (or not set up, since I didn't really change default config) SQL server. It's not a strictly a programming issue but I thought I might get some valuable feedback here.
Can anyone tell me if there is a trick, specific set of protocols, registry setting, something that will kill this delay?
I was also experiencing a 5-10 second delay on every connect, using the official Microsoft SQL drivers for PHP (as suggested by #gaRex) - none of the answers posted here solved it for me.
As suggested by #ircmaxell, my problem was a DNS issue - and the solution was to edit the \windows\system32\drivers\etc\hosts file (your local local host file) and add the name of my own machine to it.
In the "system properties" dialog, find the "computer name" of your machine - then add a line like 127.0.0.1 my-computer to your local host file.
For me, the delay occurred once more, on the following attempt to load the page - after that, it was super fast, no delay at all.
Note that this problem may occur even on a physical machine, not only on a VM.
I came across network issues when running virtual pc, everything network related is slow, try adding this entry on your registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Create new DWORD value named DisableTaskOffload and set its value to 1.
Restart the computer.
It worked for me, source.
Is it perhaps a DNS issue? I know that MySQL does a reverse DNS lookup on each login (not each connection). If you don't have a reverse dns record for your server (or your dns is slow) it can cause a major delay at login. There's an option in MySQL to disable that. I'm not sure about SQL Server, but I'd assume it may be doing something similar...
I remember the same problem, but forgot, how we have solve it.
To clarify please specify exact connect strings, your SQLserver versions and also try to start this old good utility c:\WINDOWS\system32\cliconfg.exe, which is also can bring some light.
Yes, I know, it's from 2k, but guys at m$ don't like to create client tools from scratch.
Also try to get "right" mssql client dlls for PHP.

Categories