|
Home >> FAQs/Tutorials >> MySQL Tutorials >> Index
MySQL FAQs - Administrator Tools for Managing MySQL Server
By: FYIcenter.com
Part:
1
2
3
4
(Continued from previous part...)
What Is "mysql"?
"mysql" is a command-line interface for end users to manage user data objects.
You can use "mysql" to run any standard SQL statements against the server.
For example, you use the following SQL statements to manage tables and table rows:
- "CREATE TABLE links (name VARCHAR(80));" - Creates a table called "links" with one column.
- "INSERT INTO links VALUES ('dba.fyicenter.com');" - Inserts a table row into "links" table.
- "SELECT * FROM links;" - Selects all rows from "links" table and displays them on the screen.
- "DELETE FROM links;" - Deletes all rows from "links" table.
"mysql" also allows you to run many non-SQL commands to gather information on your
data objects. Here are some good examples:
- "SHOW DATABASES;" - Displays all databases in your MySQL server.
- "USE databaseName;" - Uses the specified database as the current database.
- "SHOW TABLES;" - Displays all table in the current database.
- "DESCRIBE links;" - Displays column information of the specified table.
To know about "mysql", read other parts of this FAQ collection.
How To Use "mysql" to Run SQL Statements?
If you want to run SQL statement to your server with "mysql", you need to
start "mysql" and enter your SQL statement at the "mysql" prompt.
Here is a good tutorial exercise that shows you how to run two SQL statements with "mysql":
>cd \mysql\bin
>mysql -u root test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.24
mysql> CREATE TABLE links (name VARCHAR(80));
Query OK, 0 rows affected (0.10 sec)
mysql> INSERT INTO links VALUES ('dba.fyicenter.com');
Query OK, 1 row affected (0.02 sec)
mysql> quit;
Bye
How To Show All Tables with "mysql"?
If you want to see all the tables in a database, you run the non-SQL command "SHOW TABLES"
at the "mysql" prompt. See the following tutorial exercise for example:
>cd \mysql\bin
>mysql -u root test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 5.0.24
mysql> SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| links |
+----------------+
1 row in set (0.01 sec)
The output shows you that there is only one table in the "test" database.
What Is "mysqlcheck"?
"mysqlcheck" is a command-line interface for administrators to check and repair tables.
Here are some sample commands supported by "mysqlcheck":
- "mysqlcheck databaseName tableName" - Checks the specified table in the specified database.
- "mysqlcheck databaseName" - Checks all tables in the specified database.
- "mysqlcheck --all-databases" - Checks all tables in all databases.
- "mysqlcheck --analyze databaseName tableName" - Analyzes the specified table in the specified database.
- "mysqlcheck --repair databaseName tableName" - Repairs the specified table in the specified database.
To know about "mysqlcheck", read other parts of this FAQ collection.
(Continued on next part...)
Part:
1
2
3
4
|