User Tools

Site Tools


wamp:mysql:set_pass

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wamp:mysql:set_pass [2016/02/12 06:46] – created rpleckowamp:mysql:set_pass [2016/02/12 07:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +===Set password to MySQL server===
 +
 +//"BUILD YOUR OWN DATABASE DRIVEN WEB SITE USING PHP & MYSQL" BY KEVIN YANK 4th edition//
 +
 <code> <code>
 mysqladmin -u root status mysqladmin -u root status
 </code> </code>
 +When you hit Enter you should see a line or two of basic statistics about your MySQL server, like this:
 +<code>
 +Uptime: 102261 Threads: 1 Questions: 1 Slow queries: 0 Opens: 15
 +Flush tables: 1 Open tables: 0 Queries per second avg: 0.0
 +</code>
 +If you’re seeing a different message entirely, it’s probably one of two options. First, you might see an error message telling you that the mysqladmin program was unable to connect to your MySQL server:
 +<code>
 +mysqladmin: connect to server at 'localhost' failed
 +error: 'Can't connect to MySQL server on 'localhost' (10061)'
 +Check that mysqld is running on localhost and that the port is 3306.
 +You can check this by doing 'telnet localhost 3306'
 +</code>
 +This message normally means that your MySQL server simply isn’t running. If you
 +have it set up to run automatically when your system boots, double-check that the setup is working. If you normally launch your MySQL server manually, go ahead and do that before trying the command again.
 +Second, if you’re using MAMP on the Mac, you’ll probably see this error message
 +instead:
 +<code>
 +mysqladmin: connect to server at 'localhost' failed
 +error: 'Access denied for user 'root'@'localhost' (using password: NO)'
 +</code>
 +This error message means that the root user on your MySQL server already has a
 +password set. It turns out that, with your security in mind, MAMP comes with a
 +root password already set on its built-in MySQL server. That password, however,
 +is root—so you’re probably still going to want to change it using the instructions below.
 +One way or the other, you should now be able to run the mysqladmin program. Now
 +you can use it to set the root password for your MySQL server:
 +<code>
 +mysqladmin -u root -p password "newpassword"
 +</code>
 +Replace newpassword with whatever password you’d like to use for your MySQL
 +server. Make sure it’s one you can remember, because if you forget your MySQL
 +root password, you might need to erase your entire MySQL installation and start over from scratch! It’s usually possible to recover from such a mishap, but it’s definitely a pain in the neck.
 +
 +Let me break this command down for you, so you can understand what each part
 +means:
 +<code>
 +mysqladmin
 +</code>
 +This, of course, is the name of the program you wish to run.
 +<code>
 +-u root
 +</code>
 +This specifies the MySQL user account you wish to use to connect to your
 +MySQL server. On a brand new server, there is only one user account: root.
 +<code>
 +-p
 +</code>
 +This tells the program to prompt you for the current password of the user account. On a brand new MySQL server, the root account has no password, so
 +you can just hit Enter when prompted. It’s a good idea, however, to make a habit
 +of including this option, since most of the time you will need to provide a
 +password to connect to your MySQL server.
 +<code>
 +password "newpassword"
 +</code>
 +This instructs the mysqladmin program to change the password of the user account to newpassword. In this example, whatever password you specify will
 +become the new password for the root MySQL user.
 +Now, to try out your new password, request once again that the MySQL server tell
 +you its current status at the system command prompt, but this time include the -p option:
 +<code>
 +mysqladmin -u root -p status
 +</code>
 +Enter your new password when prompted. As before, you should see a line or two
 +of statistics about your MySQL server.
 +Since the root account is now password-protected, attempting to run this command
 +without the -p switch will give you an “Access Denied” error.
wamp/mysql/set_pass.1455259595.txt.gz · Last modified: 2016/02/12 06:46 (external edit)