Eaglenet logo
24/7 updates on happenings in africa
*LORDEAGLE 2015-07-04 19:54
This command lists all the MySQL databases on your computer. Since you've just installed MySQL, there will just be a few default databases, similar to the following:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Copy code
Now that you know how to send commands to your MySQL server, you're ready to create your own database and start adding data to it. You'll do this in the following sections.
When you're finished with the MySQL Monitor, you can quit it by typingexitat the prompt and pressingEnter.
If you're not comfortable with the command line, there are other ways to administer MySQL and issue commands. MySQL Workbenchis a free graphical app that can connect to any MySQL server and administer it. There's also the web-based phpMyAdmin, which is included in many LAMP/WAMP/MAMP packages
Creating a database
Let's create a simple database for an imaginary book store. At yourmysql>prompt, type the following and pressEnter:
create database bookstore;
If all goes well, you'll see something like this:
Query OK, 1 row affected (0.05 sec)
MySQL has now created your database. You can check this by typingshow databasesagain:[code]mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bookstore         |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Copy code

Congratulations — you've just created your first MySQL database! Hope The above tutorial was helpful?
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:53
This command lists all the MySQL databases on your computer. Since you've just installed MySQL, there will just be a few default databases, similar to the following:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Copy code
Now that you know how to send commands to your MySQL server, you're ready to create your own database and start adding data to it. You'll do this in the following sections.
When you're finished with the MySQL Monitor, you can quit it by typingexitat the prompt and pressingEnter.
If you're not comfortable with the command line, there are other ways to administer MySQL and issue commands. MySQL Workbenchis a free graphical app that can connect to any MySQL server and administer it. There's also the web-based phpMyAdmin, which is included in many LAMP/WAMP/MAMP packages
Creating a database
Let's create a simple database for an imaginary book store. At yourmysql>prompt, type the following and pressEnter:
create database bookstore;
If all goes well, you'll see something like this:
Query OK, 1 row affected (0.05 sec)
MySQL has now created your database. You can check this by typingshow databasesagain:[code]mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bookstore         |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Copy code

Congratulations — you've just created your first MySQL database! Hope The above tutorial was helpful?
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:46
This tells MySQL to get the current date and time and display it. You'll see something like this appear:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Copy code
This command lists all the MySQL databases on your computer. Since you've just installed MySQL, there will just be a few default databases, similar to the following:
+---------------------+
| now()               |
+---------------------+
| 2011-08-24 11:36:40 |
+---------------------+
1 row in set (0.00 sec)

Copy code

Now try another command:
show databases;
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:43
Issuing commands to MySQL
Assuming you've now installed and started your MySQL server using one of the above techniques, how do you interact with the server? When you installed the MySQL server, you also installedmysql, the MySQL Monitor. This is a command-line client program that you can use to connect to the server and issue commands.
So let's try firing up the MySQL Monitor and see what it can do. Follow these two steps:
1.Open a terminal window:
*.Windows 7:Click the Windows logo, then choose All Programs > Accessories > Command Prompt.
*.Mac OS X:Open a Finder window, then choose Applications > Utilities > Terminal.
*.Ubuntu:Choose Applications > Accessories > Terminal, or if you're using the Unity desktop, click the Ubuntu logo and typeterminal. ( More info)
2.Run themysqlprogram in the terminal window:
*.Windows 7:Assuming you installed XAMPP, typecd c:\xampp\mysql\binand pressEnter, then typemysql -u rootand pressEnter.
*.Mac OS X and Ubuntu:Just typemysql -u rootand pressEnter.
The-u rootparameter tells the MySQL Monitor to connect to the MySQL server using the root user, which is always available with MySQL. By default, MySQL's root user doesn't need a password. This is OK for a development setup on your computer, but a terrible idea for a live server! If you're installing MySQL on a live server, make sure you secure it properly. XAMPPalso comes with some security scripts that can automatically make your XAMPP installation more secure.
Once the MySQL Monitor runs, you'll see something like this in your terminal window:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3893
Server version: 5.5.8 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> _
The last line,mysql>, is the MySQL prompt. This is where you type your commands to send to the MySQL server.
Let's try out a couple of commands. Type the following at themysql>prompt, then pressEnter:
select now();
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:40
XAMPP makes it easy to install a complete Apache, MySQL, PHP and Perl setup on Windows, Mac and Linux.
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:40
Installing MySQL
img

As I mentioned above, most web hosting accounts come with MySQL pre-installed. However, if you're developing websites using MySQL, you also want to have the MySQL server running on your own computer, so that you can create and test your databases and code without needing to upload files to your live server all the time.
There are two main components to MySQL:
*.The MySQL database server,mysqld.This is the MySQL DBMS that does the actual work of managing your databases. It runs all the time in the background, accepting connections from client programs, web scripts and so on.
*.Various client and utility programs.These includemysql, the command-line MySQL Monitor client that you'll use later in the tutorial to issue commands to the server. You'll also find programs likemysqladminfor administering MySQL databases, andmysqldumpfor exporting and backing up databases.
In addition, many MySQL installs include documentation, header files for developers, and the MySQL test suite.
There are many ways to install the MySQL server and associated programs. Here are three ways you can do it:
*.Using an official MySQL installation package.There are prebuilt packagesavailable for many different operating systems, including Windows, Mac OS X and Linux. The basic procedure is to download the package file, extract it, and run the installer. See the documentationfor the exact steps.
*.Using a Linux package manager.Many Linux distros come with a package manager — for example, Ubuntu includes the Ubuntu Software Centre— that makes it easy to install MySQL, along with PHP, Apache and other web development software. See your distro's documentation for details.
*.Installing an entire LAMP/WAMP/MAMP package.This is arguably the easiest way to install a complete MySQL-based development setup on your computer. These packages contain all you need to start building database-driven sites, including the Apache web server, MySQL, and PHP/Perl, hence the acronym "AMP". (The L, W and M stand for Linux, Windows and Mac OS X respectively.) Since everything's installed in one go, you'll find that Apache, MySQL and PHP/Perl all play nicely together, with little or no further configuration required.
If you want to get up and running as quickly and easily as possible, I'd personally recommend downloading and installing XAMPP. This LAMP/WAMP/MAMP package is available for Linux, Windows, Mac OS X and Solaris, and automatically installs and sets up Apache, MySQL, PHP and Perl on your computer. What's more, it's easy to uninstall everything later if you want to.
To install XAMPP:
1. Visit the XAMPP homepageand click the link for your operating system (Linux, Windows, Mac OS X or Solaris).
2.Follow the steps on the page to download, install, start, and test the XAMPP system on your computer.
Other popular packages similar to XAMPP include WampServerand EasyPHPfor Windows, and MAMPfor Mac OS X.
XAMPP makes it easy to install a complete Apache, MySQL, PHP and Perl setup on Windows, Mac and Linux.
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:37
You now know why databases are useful, and how they can help you build complex websites and web apps. But why use MySQL in particular?
There are many great DBMSs out there, including MySQL, PostgreSQL, SQLite, Oracle, and SQL Server, and all of them can be used for most web development purposes.
That said, MySQL does have a few advantages for web developers compared to some other systems:
*.It's open source, which means it's free for anyone to use and modify.

*.It's widely available.MySQL can be installed on many different platforms, and it usually comes standard with most web hosting setups.

*.It's easy to use.Setting up and working with MySQL databases is relatively straightforward.

*.It works well with PHP.As of version 5.3, PHP has a native MySQL driverthat is tightly coupled with the PHP engine, making it a good choice for PHP coders.
Each DBMS has its own strengths and weaknesses. For example, PostgreSQL is also open source, is very stable, and has a great community behind it. SQLite is extremely fast and self-contained (and is also free), while Oracle and SQL Server have a lot of enterprise-level features that make it a good choice for large organizations.
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:35
Relational databases are designed to take care of all these problems. Here are some reasons to use a database instead of text files:
*.They're fast.Databases use indexes, or keys, to find records of data extremely quickly. For example, once you add a key to anemailAddressfield for member records in a database, you can retrieve a member record based on the member's email address almost instantly, no matter how many millions of members you may have in your database.
*.They're reliable.A DBMS ensures that the data in the database is read and written reliably, without corrupting the data. Many DBMSs allow you to use techniques like locking and transactions to ensure that records are inserted and updated in a predictable way.
*.They let you link records together.Relational databases let you store different types of data in groups known as tables. You can then link data together across tables. For example, you can create acustomerstable and anorderstable, then link a customer record to all the order records associated with the customer. The ability to link records across tables lets you create complex databases with lots of different types of related data.
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:33
If you haven't used a database for your website before, you may have stored data in text files such as comma-separated value (CSV) files. Here's an example of a CSV file:
username,password,emailAddress,firstName,lastName
"obasimichael","lordeagle4","lordeagle@ example.com","obasi","michael"
"maryjones","garden37","mary@ example.com","Mary","Jones"
While this technique is fine for simple data structures and small amounts of data, you quickly run into problems as your site grows. Searching and updating a very large text file is slow and prone to corruption. What's more, things start to get messy when you want to link records together, such as linking a customer record to the orders that the customer has made, and then linking each order record to the products that are in the order.
    ·
  • rated(0)
*LORDEAGLE 2015-07-04 19:30
A database (left) is a collection of related data, managed by a DBMS such as MySQL (centre). Web scripts (right) communicate with the DBMS in order to insert, update, delete and retrieve data in the database.
Why use a database?
    ·
  • rated(0)
Oniline