mysql创建数据库、表、写数据

mysql> create database ceshi;
Query OK, 1 row affected (0.01 sec)

给数据库授权,否则程序时无法连接ceshi数据库的,每次创建一个数据库都要记得给数据库授权。

mysql> grant all privileges on ceshi.* TO 'root'@'%' identified by 'jenkins@123' with grant option;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> use ceshi;
Database changed

mysql> create table if not exists test ( id int(10) PRIMARY KEY AUTO_INCREMENT, name varchar(50) NOT NULL);
Query OK, 0 rows affected (0.04 sec)

mysql> insert into test values(1,'dahuju');
Query OK, 1 row affected (0.00 sec)

mysql> insert into test values(2,'yunjisuan');
Query OK, 1 row affected (0.00 sec)

mysql> select * from test;
+----+-----------+
| id | name |
+----+-----------+
| 1 | yunjisuan |
| 2 | dashuju |
+----+-----------+
2 rows in set (0.00 sec)

 

posted @ 2018-11-24 10:50  effortsing  阅读(706)  评论(0编辑  收藏  举报