Join 149,541 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,548 people online right now. Registration is fast and FREE... Join Now!
[localhost:~] bjclark% mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 16 to server version: 3.23.49-entropy.ch
Type 'help;'or'\h' for help. Type '\c' to clear the buffer.
Warning: Access denied for user: 'root@localhost' (Using password: YES) in /Library/WebServer/Documents/test.php on line 5
Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: YES) in /Library/WebServer/Documents/test.php on line 5
Warning: Access denied for user: 'root@localhost' (Using password: NO) in /Library/WebServer/Documents/test.php on line 9
Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: NO) in /Library/WebServer/Documents/test.php on line 9
Warning: MySQL: A link to the server could not be established in /Library/WebServer/Documents/test.php on line 9
Access denied for user: 'root@localhost' (Using password: NO)
when I run this:
CODE
<? print "<pre>";
// log into our local server using the MySQL root user. $dbh = mysql_connect( "localhost", "root", "password" );
// select the 'test' database created during installation. mysql_select_db( "test" ) or die ( mysql_error() . "\n" ); print "Connection to the database has been established.\n";
$response = mysql_query( $table, $dbh ); if ($response) { print "The table was created correctly!\n"; } else { print mysql_error () . "\n"; }
// now, we'll add some data to our newly created table. // to add different wisdom, just change the 'values'. $insert_data = "INSERT into wisdom ( wisdom, author ) values ( 'Must... remain... awake!', 'Morbus' );";
$response = mysql_query( $insert_data, $dbh ); if ($response) { print "The data was inserted correctly!\n"; } else { print mysql_error () . "\n"; }
// and read it back for printing purposes. $get_table_data = "SELECT * FROM wisdom;"; $response = mysql_query( $get_table_data, $dbh ); if ($response) { print "We successfully got all the table data.\n"; } else { print mysql_error () . "\n"; }
// now print it out for the user. while ( $one_line_of_data = mysql_fetch_array( $response ) ) { extract ( $one_line_of_data ); print "#$id: $author sez: \"$wisdom\"\n"; }
If you don't have a MySQL password yet... root@localhost: /root $ mysqladmin -u root password new_pass
If you have a MySQL pass already... root@localhost: /root $ mysqladmin -u root -p password new_pass Enter password: (type current pass)
Then:
mysql -u root -p
In use:
root@localhost: /root $ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 to server version: 3.23.49
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
If you don't have a MySQL password yet... root@localhost: /root $ mysqladmin -u root password new_pass
If you have a MySQL pass already... root@localhost: /root $ mysqladmin -u root -p password new_pass Enter password: (type current pass)
Then:
mysql -u root -p
In use:
root@localhost: /root $ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 to server version: 3.23.49
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
See, but I've set it already to something but I don't know what the current root password is. I read that I could re-start it using the --skip-grant-tables, but I can't shut it down cause I don't have access and I can't kill the process cause it' just restarts automaticly.
If you used the command I gave here (or any command with the password in it), you can hit your up arrow in the terminal to go through the previous commands used. As long as it wasn't too long ago, it should be in the history.
Can't you just disable it at boot time. Have you checked the /etc/rc.d area for a reference to the safe_mysqld script. Just comment out the line and reboot.