1) login to mysql as admin user
mysql -u admin -p`cat /etc/psa/.psa.shadow`
2) login to mysql as a user with a database
mysql -u <user> -p<password> <database>
3) login to mysql as remotely
mysql -u <user> -p<password> <database> -h <ipaddress>
4)mysql table repair
myisamchk /var/lib/mysql/<dbname>/*.MYI
5) mysql process number
mysqladmin -u admin -p`cat /etc/psa/.psa.shadow` processlist -i3
6) mysql database dump
mysqldump -u admin -p`cat /etc/psa/.psa.shadow` <database name> > <file name.sql>
7) Restore a database
mysql -u admin -p`cat /etc/psa/.psa.shadow` database name < dump file
8) Grand Privilage to a user
grant all privileges on dbsbcstudio.* to 'user name'@'localhost' identified by 'password';
9) Grand Privilage to a user for all network
grant all privileges on dbsbcstudio.* to 'user name'@'%' identified by 'password';
10)flush previlages
FLUSH PRIVILEGES;
11) Creation of database
In Mysql Prompt > create database <databasename>;
12) Drop Dtabase>
Im mysql prompt > Drop database <database name>;
Export database
You can export DB in MYSQL IN Two ways.
1. Command line
2. Using PHPMYADMIN.
1. COMMAND LINE.
In command line you can back up your database using one of the following technique.
mysql> mysqldump DBname [table names];
[table names]-> your tables that u want to back up.
2.
-Open phpmyadmin
-select your DB
-select Export from top menu
-select all tables from side List.
-Check the checkbox that label "Save file as"
-click the Go button to save your DB; with all the records been saved as well.
Grant remote Mysql access
log in to mysql:
grant all privileges on dbsbcstudio.* to 'user name'@'%' identified by 'password';
FLUSH PRIVILEGES
Grand syntax
GRANT <privileges>
ON <database>
TO <user>
[IDENTIFIED BY <password>]
[WITH GRANT OPTION]
http://www.keithjbrown.co.uk/vworks/mysql/mysql_p6.php
Reset mysql user password
[ php myadmin users are mysql users, so if we need to reset password of phpmyadmin user reset the password as follows]
mysql> UPDATE user SET Password=password("Terrycav1") WHERE User="nightski"; // In this Terrycav1 is the password and nightski is uer name
mysql> FLUSH PRIVILEGES;
rpm -qa | grep -i mysql-
cp /var/lib/mysql /var/lib/mysql.bk
nano /var/cpanel/cpanel.config
And here, find for the line “mysql-version=5.0” and change it to “mysql-version=4.1”
/scripts/mysqlup --force
rpm -qa | grep -i mysql-
Safe mode access.
#service mysqld stop or
#killall mysqld
#/usr/bin/mysqld_safe –skip-grant-tables&
#/usr/bin/mysql
ADODB
=======
http://phplens.com/adodb/installation.guide.html
Mysql conection check
---------------------------------
<?php
mysql_connect("localhost", "DB_user", "password") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("DB_name") or die(mysql_error());
echo "Connected to Database";
?>