0

MySQL: I Forgot My MySQL Root Password

Don’t worry, it’s not the end of the world as we have all done it before! It’s actually quite simple to fix.

First, we shut down our MySQL server:

# /etc/init.d/mysql stop
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
mysql stop/waiting

* This error tells me service mysql stop works also.

Now, we start MySQL and skip the password file with the mysqld_safe –skip-grant-tables & command:

# mysqld_safe --skip-grant-tables &
[1] 1342
121006 17:25:03 mysqld_safe Logging to syslog.
121006 17:25:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

If your output is messed up, hit Enter on your keyboard.

Next we login as root without any password with mysql -u root

# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

We issue the following commands:
use mysql;
update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’;
flush privileges;
quit;

# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=PASSWORD("Ouwurs1QuiWr") where User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

Now we stop and restart MySQL:

/etc/init.d/mysql stop
/etc/init.d/mysql start

If you run Ubuntu: service mysql stop and service mysql start.

Now, we try and login with our new MySQL root password:

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

If you see this, type exit and you have reset your password!

If not, check your output buffer and see if you misspelled your password.

0

What Kind of VPS Do I Need To Run WordPress?

This is a very common question and there are tons of information on the Internet about what the minimum requirements are and what to avoid so let me clear up some of the confusion.

This is part of an ongoing series of “WordPress Wednesdays” and in the month of October we will discuss on this website what kind of virtual private server do we need to run WordPress, a popular content management system that operates a significant amount of websites including blogs, websites just like this and even many news websites such as from CBS Local all run WordPress because of it’s flexibility.

OpenVZ or Xen?
A very good question indeed!

OpenVZ would be the bare minimum I would use for WordPress hosting while if you have a medium to large traffic website or require a lot of plugins, caching, etc. I would go with Xen VPS hosting for WordPress hosting which is generally only a few more dollars more in comparison to OpenVZ but the performance is worth those few extra dollars.

Hardware?
A VPS server’s CPU and hardware are often overlooked by individuals who are primarily focused on price!

WordPress is not CPU intensive, however MySQL which powers the WordPress content management system is, so if you go out and get a $3 VPS which has 128mb RAM, 10gb of disk space and only one CPU – do not be surprised if that medium or high traffic WordPress based website starts to crawl!

I’m sure you see guys on forums talking about they have WordPress running on a 32mb – 64mb VPS but please do not even consider shorting yourself on memory. If you want 32mb of memory dedicated to running your WordPress blog, why did you even leave shared web hosting?

A budget motivated website owner will get a custom VPS with more than enough RAM, disk space and bandwidth but only get one or two CPUs for a website that receives thousands of visits during peak hours!

Don’t short yourself on CPU!

To put things into perspective, how many single core processor desktops and laptops do you own?

If you own one, they’re slow as molasses when you’re trying to watch high definition video right? Same concept with a virtual private server – one CPU works for DNS servers, OpenVPN servers and web servers offering static files like images and HTML files but if MySQL is involved in your project and a dependency, 2 CPU cores are a minimum I would consider with 4 or more CPUs as what would be acceptable to me.

It does not matter if you have Intel Xeon or AMD based CPUs on your server. 8 CPUs at 1Ghz with an AMD based system is just as good as 2 CPUs running at 3Ghz on an Intel Xeon system.

The problem you had when you were on shared hosting running your WordPress site was your CPU and memory was limited. Most memory available to shared web hosting customers is anywhere from 8 – 32mb to run their PHP web applications. If you have multiple plugins, including a sitemap generator, this is where you would get all the weird errors, blank pages and what generally drove you away from shared hosting to virtual private server hosting.

Conclusion:
With our first lesson on “WordPress Wednesdays”, we have learned that OpenVZ and Xen does not really matter when it comes to running a WordPress site.

With OpenVZ, all the resources are shared with “your neighbors” on the same VPS node like shared web hosting and with Xen, your resources are guaranteed. Xen is only a few more dollars than OpenVZ but I think resource guarantees are worth the few extra dollars.

We also learned that CPU is something often overlooked by VPS hosting customers but should be emphasized more than anything. Would you drive a sports car if it only had a two cylinder engine inside of it that would be fast as a lawnmower or do you want the V8 engine, with 8 cylinders powering the sports car, which could be similar to an 8 CPU core system?

Thank you and tune in for next Wednesday’s article where we discuss if we should consider Apache or nginx with our WordPress website.