johnseito Posted January 19, 2008 Share Posted January 19, 2008 Hello everyone, When we first install mySQL, does it ask for username? I only see that they asked for a password and not username. So how do we know what the user name is if we need to connect PHP to mySQL? $link = mysql_connect("******","******","*******"); Thanks Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/ Share on other sites More sharing options...
toplay Posted January 19, 2008 Share Posted January 19, 2008 The default is 'root'. You should create a username to connect to MySQL with that has the correct privileges you need. Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-443887 Share on other sites More sharing options...
johnseito Posted January 20, 2008 Author Share Posted January 20, 2008 Ok, so how do you create the username? I installed it and I don't see it anytime asking for a username. thanks. Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-443913 Share on other sites More sharing options...
DyslexicDog Posted January 20, 2008 Share Posted January 20, 2008 The easiest way to mange your mysql server is with phpmyadmin. Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-443931 Share on other sites More sharing options...
johnseito Posted January 20, 2008 Author Share Posted January 20, 2008 Ok but right now I need to know how to set up a username and make a connection, then I will try to manage it with phpmyadmin later on. I want to be able to make a connection and input the data from php into mysql and then export out of a server. so you know how I can set up a username? thanks Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-443956 Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 Log in as root then run the following making changes where appropriate. mysql> GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-443975 Share on other sites More sharing options...
johnseito Posted January 20, 2008 Author Share Posted January 20, 2008 Thanks that works. Now I could filled the from and save it into mysql but I can't get it to post on the website. The codes seems to be correct. <?php //test database, info table //login in as too if (isset($_POST['submit'])) { $link =mysql_connect("localhost","****","*****"); mysql_select_db("test"); $Name = mysql_real_escape_string($_POST['Name']); $Age = mysql_real_escape_string($_POST['Age']); $sql = "INSERT INTO info (Name,Age) VALUES ('$Name','$Age')"; if (mysql_query($sql)) { header("Location: " . $_SERVER['PHP_SELF']); } else { echo "Failed to insert a new record"; } } // Make a MySQL Connection /* $query = "SELECT * FROM info"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); echo $row['Name']. " - ". $row['Age']; */ $sql = "SELECT Name,Age,FROM info"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { echo "<html><head><title>posts</title></head><body>"; while ($row = mysql_fetch_assoc($result)) { echo "<p>{$row['Name']} - {$row['Age']}</p>"; //echo "<p>{$row['subject']}</p>"; //echo "<p>{$row['post']}</p><hr />"; } } } ?> <HTML> <HEAD> <TITLE>Add a Weblog Entry</TITLE> </HEAD> <BODY> <H1>Add an Entry</H1> <form method="POST" action="info.php"> <b>NAME:</b><br> <input type="text" name="Name"><br> <b>AGE:</b><br> <input type="text" name="Age"><br> <input type="submit" name="submit" value="Submit"> </form> </BODY> </HTML> any ideas what is going on here? The thing is that I have two output one I greyed out, that one gives an error <b>Access denied for user 'ODBC'@'localhost' (using password: NO)</b> the other one that I used below it gives nothing. I would like it to give the output of what is in the database. thanks - Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-444345 Share on other sites More sharing options...
fenway Posted January 21, 2008 Share Posted January 21, 2008 Sounds like it's not respecting your credentials. Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-445416 Share on other sites More sharing options...
johnseito Posted January 22, 2008 Author Share Posted January 22, 2008 Sounds like it's not respecting your credentials. What is not respecting my credentials? Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-445763 Share on other sites More sharing options...
fenway Posted January 23, 2008 Share Posted January 23, 2008 Your connection string. Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-447241 Share on other sites More sharing options...
johnseito Posted January 23, 2008 Author Share Posted January 23, 2008 Your connection string. my connection string pretty much have a mind of it's own. So do you know how I can fix it or what I can do to fix it? thanks- Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-447356 Share on other sites More sharing options...
johnseito Posted January 24, 2008 Author Share Posted January 24, 2008 I think my connection should be fine since I could insert data into mysql with PHP but I can't get those data onto the server. So do you know why I can pull those information out form the database? thanks Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-447430 Share on other sites More sharing options...
fenway Posted January 24, 2008 Share Posted January 24, 2008 I think my connection should be fine since I could insert data into mysql with PHP but I can't get those data onto the server. So do you know why I can pull those information out form the database? thanks I wish I did... but I don't know anything about php functions. However, I'm sure I've seen the problem addressed before, you might want to search this forum. Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-447992 Share on other sites More sharing options...
johnseito Posted January 25, 2008 Author Share Posted January 25, 2008 ok, thanks. It will take a long while for me to search for this in this forum. lol Link to comment https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-448474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.