一、安装MySQL
yum install -y mysql-server mysql
![8685807-683db27fad053f25.png](https://upload-images.jianshu.io/upload_images/8685807-683db27fad053f25.png)
启动mysqld服务,并设置开机自启动
![8685807-ac46fb9da5d61bd3.png](https://upload-images.jianshu.io/upload_images/8685807-ac46fb9da5d61bd3.png)
使用mysqladmin验证服务器正在运行,如果能看到版本号说明安装成功
![8685807-785c74485741814c.png](https://upload-images.jianshu.io/upload_images/8685807-785c74485741814c.png)
二、使用MySQ
1.进入MySQL
mysql -u root
![8685807-cc3880300abeba2a.png](https://upload-images.jianshu.io/upload_images/8685807-cc3880300abeba2a.png)
2.利用mysqladmin进行数据库操作
![8685807-aab78ff4f4832fb6.png](https://upload-images.jianshu.io/upload_images/8685807-aab78ff4f4832fb6.png)
3.设置密码之后,mysql -u root -p,输入密码之后方可使用mysql服务
![8685807-8412628825a7766a.png](https://upload-images.jianshu.io/upload_images/8685807-8412628825a7766a.png)
4.熟悉MySQL基本操作,创建与使用数据库,创建与查看数据表
![8685807-1ea1d71fe783848f.png](https://upload-images.jianshu.io/upload_images/8685807-1ea1d71fe783848f.png)
![8685807-e8bf965bb7f9dd80.png](https://upload-images.jianshu.io/upload_images/8685807-e8bf965bb7f9dd80.png)
显示表的所有内容,以及查找、插入等基本操作
![8685807-9e7b12fd0d45dcbe.png](https://upload-images.jianshu.io/upload_images/8685807-9e7b12fd0d45dcbe.png)
5.添加新用户,并为其赋予查找、插入、删除】更新等权限,同时为其设置密码123
![8685807-239b3530fe779129.png](https://upload-images.jianshu.io/upload_images/8685807-239b3530fe779129.png)
6.切换到新用户下进入MySQL
![8685807-a526520eee60d1cd.png](https://upload-images.jianshu.io/upload_images/8685807-a526520eee60d1cd.png)
因为tom只有查找权限,所以不能对mytable表进行插入操作
![8685807-b55f1b194aa0a3c6.png](https://upload-images.jianshu.io/upload_images/8685807-b55f1b194aa0a3c6.png)
切换到Jack,可以看到jack可以进行插入操作
![8685807-e15eef45dc8fdc70.png](https://upload-images.jianshu.io/upload_images/8685807-e15eef45dc8fdc70.png)
![8685807-39cda0ea22fca23d.png](https://upload-images.jianshu.io/upload_images/8685807-39cda0ea22fca23d.png)
![8685807-883b528beaf3d1bd.png](https://upload-images.jianshu.io/upload_images/8685807-883b528beaf3d1bd.png)
7.可以对赋予的权限收回
revoke insert on news.* from jack@localhost //于是Jack也不能再进行插入操作
![8685807-adb075531d0dd8e7.png](https://upload-images.jianshu.io/upload_images/8685807-adb075531d0dd8e7.png)
8.在创建表格的同时,指定铸件,主键非空且唯一
![8685807-154307596519c143.png](https://upload-images.jianshu.io/upload_images/8685807-154307596519c143.png)
9.利用host和port可以建立一个防火墙数据库表。
![8685807-eeeb2b0beb29d4aa.png](https://upload-images.jianshu.io/upload_images/8685807-eeeb2b0beb29d4aa.png)
根据实验吧实验编写:Linux下mysql数据库安装与使用