Archive

Archive for the ‘MySQL and databases’ Category

What is FTP and what are the requirements for connecting FTP

October 7th, 2009

FTP (File Transfer Protocol), is a way of moving files from one machine to another. FTP is the most common way to update a web site with contribute.

To connect to an FTP server with Contribute, you must have the following basic information:-

1.The site address:- Example: http://www.domain.com . The site address is the URL which you use to navigate to a site in a browser. When you put a URL address into a browser, the browser looks to the HTTP server for that information.

2.The FTP server address:- The FTP server address may have an ftp prefix, such as ftp.domain.com, or it may look like a standard url, such as www.domain.com .

3.User name and password:- FTP account information which may differ from other server login information.

4.The location of the web files on the server:- You have to upload the web files for your website to the web directory for your website . For example, /public_html/ means that your website’s files are contained in a folder called public_html, which is in the root folder(/home/username) of the website.

FTP related issues, MySQL and databases

Required properties to connect DB from scripts ?

October 6th, 2009

The most important properties required to connect DB from scripts ( PHP,CGI or Perl ) are

database server : localhost
database name : cpanelusername_testdb
database username : cpanelusername_dbuser
database user password : *****

Note: DB server name is always “localhost”. It means they connect to DB only from scripts inside the server. If the client trying to connect DB from his pc ( remotely ) then he will get errors becuase we have blocked mysql remote port 3306. Clients are not allowed to connect DB remotely.

MySQL and databases

Mysql daily backup through Cronjob

October 6th, 2009

You can use following code to setup daily cron job to take database backup.

Quote:
—————————————–
year=$(date|cut -c25-2Cool
month=$(date|cut -c5-7)
day=$(date|cut -c9-10)
mysqldump -hlocalhost -uusername –password=password –opt yourdbname > /home/username/www/voice/db_voice$year$month$day.sql
echo .
echo DATABASE BACKUPS COMPLETE
echo .
—————————————–

The parts in red you will have to change to your username, password and dbname.
Please note that from mysqldump………. to db_voice$year$month$day.sql is all one line.

The parts in blue is the path/filename of the file you want to save the DB to, in my case db_voice. The $year$month$day just ensures that each backup file has a different name, i.e. the date of the backup is part of it as well.

The cronjob that calls the backup script is:

15 0 * * * /home/username/www/voice/backup_dbs > /dev/null

This runs the backup at 00:15 each morning and the orange is the full path to the script above, so you will need to change this to point to the location of your script.

MySQL and databases

Export & Import Mysql DB using?

October 6th, 2009

You can find phpMyAdmin
cpnel -> MySql -> [Go to Bottom of the page] phpMyAdmin

One of the most common tasks a database administrator performs is the frequent backup of the data in a database. phpMyAdmin simplifies this task via its “Export” module, which makes it possible to export the structure and contents of a database or table to a variety of different formats, either for backup or to migrate data from one database to another.

This module is accessible from the main application page, via the “Export” link.

Using this module is simplicity itself - all you have to do is select the databases to be exported, the format of the output file, and whether you would like the output file to contain the table definitions, the table contents or both. A number of different output formats are available - you can have your data exported as regular SQL queries, as comma-separated values, or as LaTEX-formatted data. You can also choose to either view the exported output directly in your browser (useful if you’re trying to quickly obtain information on the structure of a table) or save it to a file for archival or import into another application.

As with all good export modules, the output file created by phpMyAdmin can be imported back into the application to recreate the database. Simply select the appropriate database (or create a new one as needed), switch to the SQL tab of the database module, and give phpMyAdmin the location of the output file.

The application will now automatically take care of detecting the file format and importing its contents into the selected database.

That’s It. Now there is no need to use mysqldump command from the shell.

MySQL and databases

/tmp/mysql.sock errors ?

October 6th, 2009

Do following things for
Warning: mysql_connect(): Can’t connect to local MySQL server through
socket ‘/var/tmp/mysql.sock’

edit /etc/my.cnf

Make sure that it has the following:

code:——————————————————————————–[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock——————————————————————————–
If not, then add the above. Save, close and then execute

service mysql start
service chksrvd start
ln -s /tmp/mysql.sock /var/tmp/mysql.sock
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

MySQL and databases

Mysql gives error of access denied for root ?

October 6th, 2009

Make sure root pass is in /root/.my.cnf
This is usually the first mysql root pass the box was given once cpanel is installed.
If it still does not work, you will need to reset the mysqld root pass.

First, stop the mysqld, usually
/etc/rc.d/init.d/mysql stop

Then stop chkservd to keep it from interfering with mysqld while you work on it
with /etc/rc.d/init.d/chkservd stop

Start up mysqld , but, without the grant tables,

mysqld –skip-grant-tables -u mysql &

Then change the pass..

mysql -u root mysql

UPDATE user SET Password=PASSWORD(’new_password’) WHERE user=’root’;

FLUSH PRIVILEGES;

Now you just
killall -9 mysqld

and start it up normally with it’s safe_mysqld script..

safe_mysqld –skip-grant-tables & /usr/local/cpanel/startup

MySQL and databases

MySQL DOWN and Errors ?

October 6th, 2009

/usr/bin/mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)’
Check that mysqld is running and that the socket: ‘/var/lib/mysql/mysql.sock’ exists!

Solution::

step by step

login via ssh

run the commands as follows:

killall mysqld
safe_mysqld –skip-grant-tables &
/usr/local/cpanel/startup

Then login into WHM reset the MySQL root
password.

go back to ssh…

killall mysqld
/etc/rc.d/init.d/mysql start

MySQL and databases

Getting Started with MySQL

October 6th, 2009

Here is the link to know basics of MySql data base server.
http://www.mysql.com/articles/mysql_intro.html

MySQL and databases

phpmyadmin showing all databases on server

October 6th, 2009

1) Login to shell as root

2) And give the following commands :

a) mysql

b) use mysql

c) update user set Create_tmp_table_priv=’Y’ where Create_tmp_table_priv=’N';

d)update user set Lock_tables_priv=’Y’ where Lock_tables_priv=’N';

e) update `user` set Create_tmp_table_priv = ‘N’, Lock_tables_priv = ‘N’ where user <> ‘root’;

flush privileges;

e) quit

3) service mysql restart

MySQL and databases

What is innoDB - enabling it.

October 6th, 2009

nnoDB.

innoDB is a table type in mySQL.

InnoDB provides MySQL with a transaction-safe storage engine with commit, rollback, and crash recovery capabilities. InnoDB does locking on the row. These features increase multi-user concurrency and performance. There is no need for lock escalation in InnoDB because row-level locks in InnoDB fit in very little space.

advantages of innoDB table type are :

* InnoDB tables are transactional: they provide rollback and commit capabilities.
* InnoDB is the only table type in MySQL which supports foreign key constraints.
* InnoDB tables are fast, even faster than MyISAM tables in many simple benchmarks. See the benchmark page.
* InnoDB tables have row level locking: they allow higher concurrency than MyISAM tables which use table level locking, or BDB tables, which use page level locking. High concurrency is reflected in high multiuser performance.
* InnoDB tables provide an Oracle-style consistent read, also known as multiversioned concurrency control. SELECTs do not need to set any locks and need not interfere with inserts and updates to the same table. No other MySQL table type has this property.
* There is a true hot backup tool available for InnoDB, which allows you to make backups of a running database in background, without setting any locks or disturbing database operation.
* Multiversioning also allows you to dump tables from your database with SELECT INTO OUTFILE without setting locks on the tables: the database can keep working while a backup is made.
* InnoDB tables have automatic crash recovery. You do not need to repair your tables if the operating system or the database server crashes, when there is no disk image corruption.
* InnoDB tables can be any size, also on those operating systems where file size is restricted to < 2 GB.

Enabling and Checking innoDB type in mySQL

innoDB type is supported my all mySQL versions starting from mySQL 4.0.x

Go to the file /etc/my.cnf file and either comment out the line or delete the line ’skip-innodb’ and innodb will be enabled.

You can check either your mySQL supports the innoDB type by giving the following command at mysql prompt.

mysql> show variables like ‘have_innodb’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| have_innodb | YES |
+—————+——-+
1 row in set (0.00 sec)

MySQL and databases