Welcome to Onlinetunes24 .....

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 1 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 2 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 3 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 4 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

Import sql/txt file from mysql console


  1. Go to run (WinKey+R) 
  2. Type “cmd”
  3.  Run mysql console (e.g: d:\server\mysql\bin\mysql.exe -u root)
  4.  Connect database  
  5. Type “source c:\mydb.txt;”

MySQL User/Password


o   Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;


o   Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'


o   Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;


o   Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start


o   Set a root password if there is on root password.

# mysqladmin -u root password newpassword


o   Update a root password.

# mysqladmin -u root -p oldpassword newpassword


o   Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;


o   Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

MySQL Commands

o   To login (from unix shell) use -h only if needed. 
# [mysql dir]/bin/mysql -h hostname -u root -p

o   Create a database on the sql server. 
mysql> create database [databasename];

o   List all databases on the sql server.
mysql> show databases;

o   Switch to a database.
mysql> use [db name];

o   To see all the tables in the db.
mysql> show tables;

o   To see database's field formats.
mysql> describe [table name];

o   To delete a db. 
mysql> drop database [database name];

o   To delete a table. 
mysql> drop table [table name];

o   Show all data in a table.
mysql> SELECT * FROM [table name];

o   Returns the columns and column information pertaining to the designated table.
mysql> show columns from [table name];

o   Show certain selected rows with the value "whatever".
mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

o   Show all records containing the name "Bob" AND the phone number '3444444'.
mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

o   Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.
mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

o   Show all records starting with the letters 'bob' AND the phone number '3444444'.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

o   Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

o   Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.
mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

o   Show unique records.
mysql> SELECT DISTINCT [column name] FROM [table name];

o   Show selected records sorted in an ascending (asc) or descending (desc).
mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

o   Return number of rows.
mysql> SELECT COUNT(*) FROM [table name];

o   Sum column.
mysql> SELECT SUM(*) FROM [table name];

o   Join tables on common columns.
mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

MySQL command line with XAMPP

Some developers still like to use the command line feature of MySQL other than phpMyAdmin. the main advantage of the command line is fast accessing. and it’s can access any platform too. 
To work with command line on your XAMPP installation, first go to your command line on windows and find MySQL “bin” folder.

1. type “cmd” on run box in windows.
2. type cd c:\xampp\mysql\bin (specify drive letter if your XAMPP not in c: drive)
3. type mysql.exe -u root -p {password}

that’s it. now you can run your MySQL queries.

XAMPP

XAMPP- A software,  an Integrated development environment for developing dynamic web site.

Apache: A web server.

MySQL: MySQL is a full fledged relational database management system, ideally suited to run as a server in a high volume, mission critical environment.

PHP: PHP hypertext processor is a server side scripting language.
 
phpMyAdmin: Web based graphical user interface for MySQL Server.

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle