MySQL Basic management and application

Source: Internet
Author: User

# yum Install Mysql-server

#/etc/init.d/mysqld Start
Initializing mysql database:installing mysql system tables ...
Ok
Filling Help Tables ...
Ok

To start mysqld at boot time with to copy
Support-files/mysql.server to the right place for your system

REMEMBER to SET A PASSWORD for the MySQL root USER!
To does so, start the server, then issue the following commands:

/usr/bin/mysqladmin-u root password ' new-password '
/usr/bin/mysqladmin-u root-h CentOS1.eric.com password ' new-password '

Alternatively you can run:
/usr/bin/mysql_secure_installation

Which would also give you the option of removing the test
Databases and anonymous user created by default. This is
Strongly recommended for production servers.

See the Manual for more instructions.

You can start the MySQL daemon with:
CD/USR; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
Cd/usr/mysql-test; Perl mysql-test-run.pl

Problems with The/usr/bin/mysqlbug script!

=============================================================================================================== =============================
# mysqladmin-u root password ' password '
# mysql-u Root-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 4
Server version:5.1.61 Source Distribution

Copyright (c), +, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Test |
+--------------------+
3 Rows in Set (0.00 sec)

mysql> CREATE DATABASE WordPress;
Query OK, 1 row affected (0.02 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Test |
| WordPress |
+--------------------+
4 rows in Set (0.00 sec)
Mysql> Grant all privileges on * * to ' wordpress ' @ ' localhost ' identified by ' WordPress ' with GRANT OPTION;
Query OK, 0 rows Affected (0.00 sec)


Mysql> CREATE database Bank;
Query OK, 1 row Affected (0.00 sec)

mysql> CREATE DATABASE shop;
Query OK, 1 row Affected (0.00 sec)

Mysql> CREATE Database Hospital;
Query OK, 1 row affected (0.01 sec)


Mysql> Grant Select,insert,update,delete,create,drop
-On bank.*
-To ' custom ' @ ' localhost '
-Identified by ' obscure ';
Query OK, 0 rows Affected (0.00 sec)

Mysql> Grant Select,insert,update,delete,create,drop on shop.*-' custom ' @ ' localhost ' identified by ' obscure ';
Query OK, 0 rows Affected (0.00 sec)

Mysql> Grant Select,insert,update,delete,create,drop on hospital.*-' custom ' @ ' localhost ' identified by ' obscure ';
Query OK, 0 rows Affected (0.00 sec)
=============================================================================================================== =============================
# mysql Bank-u custom-p
mysql> use bank;
Mysql> CREATE TABLE Pet (name varchar), owner varchar ($), species varchar, sex CHAR (1), Birth date, death date) ;
Query OK, 0 rows affected (0.03 sec)
Mysql> Show tables;
+----------------+
| Tables_in_bank |
+----------------+
| Pet |
+----------------+
1 row in Set (0.00 sec)

Mysql> DESC Pet;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name | varchar (20) | YES | | NULL | |
| Owner | varchar (20) | YES | | NULL | |
| Species | varchar (20) | YES | | NULL | |
| sex | char (1) | YES | | NULL | |
| Birth | Date | YES | | NULL | |
| Death | Date | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
6 rows in Set (0.00 sec)

Mysql> INSERT into pet values (' Puffball ', ' Diane ', ' hamster ', ' f ', ' 2001-02-01 ', NULL);
Query OK, 1 row affected (0.01 sec)
Mysql> INSERT into pet values (' Puffbffff ', ' Eric ', ' Hamster ', ' f ', ' 2022-02-01 ', NULL);
Query OK, 1 row Affected (0.00 sec)
Mysql> INSERT into pet values (' Pub ', ' laszy ', ' hamster ', ' f ', ' 2222-02-01 ', NULL);
Query OK, 1 row Affected (0.00 sec)

Mysql> select * from pet;
+-----------+-------+---------+------+------------+-------+
| name | Owner | Species | sex | Birth | Death |
+-----------+-------+---------+------+------------+-------+
| Puffball | Diane | Hamster | f | 2001-02-01 | NULL |
| PUFFBFFFF | Eric | Hamster | f | 2022-02-01 | NULL |
| Pub | Laszy | Hamster | f | 2222-02-01 | NULL |
+-----------+-------+---------+------+------------+-------+
3 Rows in Set (0.00 sec)


Mysql> SELECT * from pet where name= ' Pub ';
+------+-------+---------+------+------------+-------+
| name | Owner | Species | sex | Birth | Death |
+------+-------+---------+------+------------+-------+
| Pub | Laszy | Hamster | f | 2222-02-01 | NULL |
+------+-------+---------+------+------------+-------+
1 row in Set (0.00 sec)

Mysql> Select name, owner from pet;
+-----------+-------+
| name | owner |
+-----------+-------+
| Puffball | Diane |
| PUFFBFFFF | Eric |
| Pub | Laszy |
+-----------+-------+
3 rows in Set (0.00 sec)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.