Old school Easter eggs.
Eaglenet logo
24/7 updates on happenings in africa
*LORDEAGLE 2015-07-05 04: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-05 04: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-05 04: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-05 04: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)
Oniline