Tuesday, September 27, 2011

แก้ไขรหัสผ่าน root ของ MySQL


MySQL: Resetting the Root Password: Generic Instructions

The preceding sections provide password-resetting instructions for Windows and Unix systems. Alternatively, on any platform, you can set the new password using the mysql client (but this approach is less secure):

Stop mysqld and restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges. If you normally start the server with the --old-passwords option, include that option as well.

Connect to the mysqld server with this command:

shell> mysql
Issue the following statements in the mysql client. Replace the password with the password that you want to use.

mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
    ->                   WHERE User='root';
mysql> FLUSH PRIVILEGES;
The FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.

You should now be able to connect to the MySQL server as root using the new password. Stop the server and restart it normally
(without the --skip-grant-tables option).

Friday, September 02, 2011

การติดตั้ง SUN-Oracle Java 1.7.0 บน CentOS 6.0 (HowTo Install SUN-Oracle Java 1.7.0 on CentOS 6.0)


การติดตั้ง SUN-Oracle Java 1.7.0 บน CentOS 6.0 (HowTo Install SUN-Oracle Java 1.7.0 on CentOS 6.0)

Step-1: ตรวจสอบเวอร์ชั่นของ Java บน CentOS จะเห็นได้ว่าเป็น Java OpenJDK
[root@bitcentos]#  java  -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.9) (rhel-1.36.b17.el6_0-x86_64)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

Step-2: เปลี่ยนโฟลเดอร์ไปที่  /usr/src
[root@bitcentos]#  cd  /usr/src

Step-3: สร้างโฟลเดอร์  /usr/src/downloads
[root@bitcentos]#  mkdir  downloads

Step-4: เปลี่ยนโฟลเดอร์ไปที่  /usr/src/downloads  เพื่อจัดเก็บไฟล์ดาวน์โหลด Java ลงที่โฟลเดอร์นี้
[root@bitcentos]#  cd  downloads

Step-5: ตรวจสอบโฟลเดอร์ปัจจุบัน ด้วยคำสั่ง pwd
[root@bitcentos]#  pwd
/usr/src/downloads

Step-6: ดาวน์โหลดไฟล์ RPM ชุดติดตั้ง jdk เวอร์ชั่น 1.7.0 แบบ 64 บิต ด้วยคำสั่ง  curl
[root@bitcentos]#  curl  -L  -O  'http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.rpm'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 77.9M  100 77.9M    0     0  1183k      0  0:01:07  0:01:07 --:--:-- 1035k

Notes: รูปแบบคำสั่งและ URL สำหรับดาวน์โหลดชุดติดตั้ง Java อื่นๆ
- ชุดติดตั้ง jdk เวอร์ชั่น 1.7.0 แบบ 32 บิต
# curl  -L  -O  'http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.rpm'
- ชุดติดตั้ง jre เวอร์ชั่น 1.7.0 แบบ 64 บิต
# curl  -L  -O  'http://download.oracle.com/otn-pub/java/jdk/7/jre-7-linux-x64.rpm'
- ชุดติดตั้ง jre เวอร์ชั่น 1.7.0 แบบ 32 บิต
#  curl  -L  -O  'http://download.oracle.com/otn-pub/java/jdk/7/jre-7-linux-i586.rpm'
- ชุดติดตั้ง jre เวอร์ชั่น 1.6.0 แบบ 64 บิต
#  curl -L -O  'http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jre-6u27-linux-x64-rpm.bin'
- ชุดติดตั้ง jre เวอร์ชั่น 1.6.0 แบบ 32 บิต
#  curl -L -O  'http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jre-6u27-linux-i586-rpm.bin'


Step-7: ติดตั้ง jdk เวอร์ชั่น 1.7.0 แบบ 64 บิต ด้วยคำสั่ง  yum
[root@bitcentos]#  yum  --nogpgcheck  localinstall  jdk-7-linux-x64.rpm


Step-8: ลงทะเบียน Java Compiler เวอร์ชั่น 1.7.0 แบบ 64 บิต  ด้วยคำสั่ง alternatives
[root@bitcentos]#  /usr/sbin/alternatives  --install  "/usr/bin/javac"  "javac"  "/usr/java/jdk1.7.0/bin/javac"  3


Step-9: ลงทะเบียน Java Runtime Environment (JRE) เวอร์ชั่น 1.7.0 แบบ 64 บิต ด้วยคำสั่ง alternatives
[root@bitcentos]#  /usr/sbin/alternatives  --install  "/usr/bin/java"  "java"  "/usr/java/jdk1.7.0/bin/java"  4


Step-10: สวิทช์คอมไพเลอร์ของ Java Development Kit (JDK) ของ CentOS ให้ใช้ SUN (Oracle) JDK แทน OpenJDK โดยการเลือกข้อ (2) - /usr/java/jdk1.7.0/bin/javac
[root@bitcentos]#  /usr/sbin/alternatives  --config  javac

There are 2 programs which provide 'javac'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.6.0-openjdk.x86_64/bin/javac
   2           /usr/java/jdk1.7.0/bin/javac

Enter to keep the current selection[+], or type selection number: 2


Step-11: ตรวจสอบเวอร์ชั่น Java Compiler
[root@bitcentos]#  javac  -version
javac 1.7.0


Step-12: สวิทช์คำสั่ง Java Runtime Environment (JRE) ของ CentOS ให้ใช้ของ SUN (Oracle) JRE แทน OpenJRE โดยเลือกข้อ (4) - /usr/java/jdk1.7.0/bin/java
[root@bitcentos]#  /usr/sbin/alternatives  --config  java

There are 4 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
*+ 2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   3           /usr/java/jdk1.7.0/bin/javac
   4           /usr/java/jdk1.7.0/bin/java

Enter to keep the current selection[+], or type selection number: 4


Step-13: ตรวจสอบเวอร์ชั่น Java Runtime Environment (JRE)
[root@bitcentos]#  java  -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

Good Luck!