azunoman Posted November 13, 2011 Share Posted November 13, 2011 Hi, long time fan of the phpfreaks. I have a cron job that creates sub/domains using PHP, I received an error creating a sites mysql db username: "Unable to create database: Database user name is invalid." The MYSQL username I was trying to add was: soloparaafiliado, and is the subdomain name. Obviously I need to check my generated MYSQL username so that it doesn't get rejected. I have no requirement that the MYSQL username be the same as the subdomain. Beat around the web looking for some guideline on the allowed formats of a MYSQL username but didn't find anything obvious. Curious if there any information of valid username format. Any help would be great appreciated. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 13, 2011 Share Posted November 13, 2011 You should be logging the actual mysql_error() [edit: and the actual query statement] so that you know why the query failed. There's nothing in the visible part of that name that would be a problem. You likely have some white-space/non-printing character before or after that string that either should be trimmed off or filtered out. Quote Link to comment Share on other sites More sharing options...
azunoman Posted November 13, 2011 Author Share Posted November 13, 2011 Great reply PFMaBiSmAd, thank you! I left out many details in my post and I apologize, I call the PLESK 9 CLI via shell_exec db --create. I went to the PLESK panel manager and entered it manually and it worked. I never really liked using the subdomain name for the db username, I will take this opportunity to use a php rand to create the db username. sorry marked as resolved...my bad...I will come back and post the sql command Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.