Archive for the Category »Mysql + phpmyadmin «

How to check mysql servers set values?

Most of the time we need to check the mysql value set on server and most of the techs checks /etc/my.cnf file.If you want to check all values set in mysql on server. We can use following simple command.

mysqld –no-defaults –verbose –help

phpmyadmin error “Cannot start session without errors”?

The most common problem in newly installed cPanel server is as follows after browsing the phpmyadmin problem.

phpmyadmin

“cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.”

To resolve above error you need to change the values in /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini file.

root@gunjan[~]#pico /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini
And than change the following values in php.ini file

FROM:
—–
session.save_handler = sqlite
session.save_path =/var/cpanel/userhomes/cpanelphpmyadmin/sessions/phpsess.sdb

—–

TO
—–
session.save_handler = files
session.save_path = /tmp

Note : To make change the values in php.ini you need to login into as root user.

How to repair mysql database table manually?

You can repair the database table manually from shell by using following command.

root@gunjan[~]mysql>mysql –u databaseusername –p databasename

For example if we are using database gunjan_db

root@gunjan[~]mysql

mysql> use gunjan_db;
Database changed

mysql> show tables;

+———————————————+
| Tables_in_gunjan_db              |
+———————————————+
| additional_images
| address_book
| address_format
| administrators
| banners
| banners_history
| cache
| categories
| categories_description
| configuration
| configuration_group

| counter

| orders_products
| orders_products_attributes
| orders_products_download
| c
| orders_status_history
| orders_total

For example we need to repair table orders_status

mysql> repair table orders_status;
+————————————+——–+———-+———-+
| Table                              | Op     | Msg_type | Msg_text |
+————————————+——–+———-+———-+
| gunjan_db.orders_status | repair | status   | OK       |
+————————————+——–+———-+———-+
1 row in set (0.11 sec)

mysql> q
Bye

Backup of mysql database using cron job.

To generate the backup of mysql database using cron job refer following three format as per your requirement.

1) Cron job to generate  database backup in  .sql format

* * * * * /usr/bin/mysqldump -u databaseusername databasename -ppassword > /path of database database.sql

2) Cronjob to compress database backup in .bz2 format

* * * * * /usr/bin/mysqldump -u datbaseusername databasename -pdatbasepassword|bzip2 -c > /path of database database.bz2

3)  Cronjob to compress database backup in .gz format

* * * * * /usr/bin/mysqldump -u databaseusername databasename -ppassword|gzip > /path of databasedatabase.gz

If you have any problem or idea about this thread than contact me at nsk.gunjan@gmail.com

mysql has failed, please contact the sysadmin (result was “mysql has failed”).

Now a most common problem we are facing with the mysql on newly installed server if we have mysql 5 we mostly receive following error message when starting mysql service from WHM

“mysql has failed, please contact the sysadmin (result was “mysql has failed”).”

As well as when ever we run mysql from shell its gives error message

“Access denied for user ‘root’@'localhost’ (using password: YES)”.

In that case we need to remove mysql from server and reinstall it by using following commands.

1)Login into server as root user

root@Gunjan [~]# which mysql
/usr/bin/mysql

root@Gunjan [~]#mv /usr/bin/mysql /usr/bin/mysql-back

root@Gunjan [~]mv /var/lib/mysql /var/lib/mysql-back

root@Gunjan [~]/scripts/mysqlup  –force

Now reset the root password from WHM >> Main >> SQL Services >> MySQL Root Password

Now you will able to access mysql without any problem :)


Some time above solution also not allowing to access mysql still throws following error message.

root@server[~]#mysql
“Access denied for user ‘root’@'localhost’

In that case refer following steps but carefully as it will cause you database loss.

root@server[~]#/etc/init.d/mysql stop

root@server[~]#mv /var/lib/mysql/ /var/lib/mysql-back

root@server[~]#mv /etc/my.cnf /etc/my.cnf-back

root@server[~]#/scripts/mysqlup –force

root@server[~]#/etc/init.d/mysql start

root@server[~]#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1430564
Server version: 5.0.85-community MySQL Community Edition (GPL)

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

mysql> \q
Bye

Now you can restore the databases from /var/lib/mysql-back to /var/lib/mysql

How to set Sim link or Symbolic link?

Basically Sim link or Symbolic link  is a type of File that contains a reference to another File/Directories  in the form of an absolute and that affects path name.

The format for Sim link or Symbolic link is as follows

ln -s <file name> in the directory you want to make a link from.

For example

To set mysql Sim link or Symbolic link

ln -s  ../../var/lib/mysql/mysql.sock mysql.sock

or

ln -s /var/lib/mysql/mysql.sock mysql.sock

You need to use above Sim link or Symbolic link as per your mysql setp.
Symbolic link,add Symbolic link,Sim link,add Sim link,what is Sim link

Simple php script to check database connection?

To check the database connection script you can use following code under your domain

<?php
mysql_connect(“localhost”, “admin”, “1admin”) or die(mysql_error());
echo “Connected to MySQL<br />”;
mysql_select_db(“test”) or die(mysql_error());
echo “Connected to Database”;
?>

After browsing the database connection script you will see following content if database connect to your server.

Connected to MySQL
Connected to Database


MySql server error “Client does not support authentication protocol”.

After upgrade server to 5.1 generally we are getting following error message.

Client does not support authentication protocol requested by server; consider upgrading MySQL client.

The above error message are receiving because latest version of MySql uses a new format for the password in that case to use older client to use older version Mysql with new version Mysql you have to set the passwords on the server to their old format.Refer following steps to set the password.

Login into shell as root user and access mysql with root user and password

[root@gunjan.com]#mysql -u root -p

Then, copy and paste the following command in shell, editing commands if necessary, to change the password of the user to the old format.

[root@gunjan.com]#UPDATE mysql.user
[root@gunjan.com]#SET password=OLD_PASSWORD(‘password’)
[root@gunjan.com]#WHERE user=’username’
[root@gunjan.com]#AND host=’host’;

After running above commands flush the tables.

[root@gunjan.com]#flush privileges;

Then exit the mysql client.

[root@gunjan.com]#\q

It will sort your problems :)

phpmyadmin shows old mysql version?

After upgrading mysql still showing old version then run following script on server

/scripts/makecpphp