以下为个人学习时的笔记,正在完善中。。。。。。。。。。。
【1】启动服务
[root@bogon /]# service mysqld start
正在启动 mysqld: [确定]
[root@bogon /]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
【2】查看默认设置
mysql> select user,host,password from mysql.user;
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | bogon | |
| root | 127.0.0.1 | |
| | localhost | |
| | bogon | |
+------+-----------+----------+
5 rows in set (0.00 sec)
mysql>
【3】设置root用户密码
mysql> update mysql.user set password=PASSWORD('djg123')where User='root';
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>
【4】更改成功
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *2BE7655D6B576E2BBC1D1ECF9261F72CD0FCB539 |
| root | bogon | *2BE7655D6B576E2BBC1D1ECF9261F72CD0FCB539 |
| root | 127.0.0.1 | *2BE7655D6B576E2BBC1D1ECF9261F72CD0FCB539 |
| | localhost | |
| | bogon | |
+------+-----------+-------------------------------------------+
5 rows in set (0.00 sec)
mysql>
【5】查看有哪些数据库
mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)
【6】使用test数据库,作为测试样例
mysql> use test;
Database changed
mysql> show tables;
Empty set (0.01 sec)
【创建表格,并插入数据】
mysql> create table user (name varchar(20),password char(20),id int(5));
Query OK, 0 rows affected (0.03 sec)
mysql> insert into user values('Tom','tomok',5);
Query OK, 1 row affected (0.00 sec)
mysql> select * from user;
+------+----------+------+
| name | password | id |
+------+----------+------+
| Tom | tomok | 5 |
+------+----------+------+
1 row in set (0.00 sec)
mysql> quit
Bye