Archive for category Tuto

Recover MySQL root password

You can recover MySQL database server password with following five easy steps.

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password

Step # 3: Connect to mysql server as the root user

Step # 4: Setup new root password

Step # 5: Exit and restart MySQL server

Here are commands you need to type for each step (login as the root user):

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &
Output:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:

# mysql -u root
Output:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+  Done                    mysqld_safe --skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

How to install phpMyAdmin – 2.11.3 on CentOS 5.

  1. $ su -
  2. # cd /var/www/html
  3. # wget -c http://prdownloads.sourceforge.net/phpmyadmin/
    phpMyAdmin-2.11.3-english.tar.gz?download
  4. # tar xvfz phpMyAdmin-2.11.3-english.tar.gz
  5. # mv phpMyAdmin-2.11.3-english phpmyadmin
  6. # cd phpmyadmin
  7. # cp config.sample.inc.php config.inc.php
  8. # vi config.inc.php
    :
    $cfg['Servers'][$i]['auth_type'] = ‘http‘; # default is cookies
    :
  9. # service httpd restart

You can test by open phpmyadmin by this link :

http://your.domain.com/phpmyadmin/

You should be find pop up for insert your user name and password.

No Comments

Install PHPMyAdmin on Centos 5 Server

PHPMyAdmin

Download and install the latest stable release of phpMyAdmin. At the time of writing this is 3.0.0

[root@cyber ~]# cd /usr/src/
[root@cyber src]wget http://internode.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.0.0-all-languages.tar.gz
tar -xzf phpMyAdmin-3.0.0-all-languages.tar.gz
mv /usr/src/phpMyAdmin-3.0.0-all-languages /var/www/html/phpMyAdmin
cd /var/www/html/phpMyAdmin
cp config.sample.inc.php config.inc.php

Next we need to configure phpMyAdmin to use the MySQL user and password specified earlier. (we’ll jump straight in at line 30)

vim +30 config.inc.php

change line 30 to read:

$cfg['Servers'][$i]['auth_type'] = ‘config’;
at line 35 add
$cfg['Servers'][$i]['user'] = ‘root’;
$cfg['Servers'][$i]['password'] = ‘mypassword’;
Browse to your server (e.g. http://192.168.0.10/phpMyAdmin) and check phpMyAdmin is working.
Next we need to secure the directory
To do this we first meed to tell Apache to act on .htacess files in the web folders. To do this we will modify line 326 of the http.conf file.
vim +326 /etc/httpd/conf/httpd.conf
Change the line to read AllowOverride All
Save the file and restart the Apache service:
/etc/init.d/httpd restart
Next we need to create an access control file:
vim /var/www/html/phpMyAdmin/.htaccess

Insert the following text:

AuthName "phpMyAdmin"
AuthType Basic
AuthUserFile /var/www/html/phpMyAdmin/.htpasswd
AuthGroupFile /dev/null
require user MySQLAdmin
Save the file and create a password file containing the password for the user MySQLAdmin:
htpasswd -c /var/www/html/phpMyAdmin/.htpasswd MySQLAdmin
When prompted input your password and confirm.
Your phpMyAdmin page is now password protected with the user MySQLAdmin and the password you specified.

PhpInfo

phpInfo gives a handy output of installed options,versions and cofig of your LAMP server

mkdir  /var/www/html/phpInfo
vi /var/www/html/phpInfo/index.php
Insert the following text:
<?php
phpinfo();
?>

Save the file.

phpInfo can be viewed by browsing to http://yourdomain.com/phpInfo

No Comments