云计算基础架构平台构建与应用基于centos6.5
(三)Linux下MySQL数据库的安装与配置
实训涉及节点
controller compute
实训目标
- 完成MySQL数据库包的安装;
- 完成MySQL数据库配置文件的修改;
- 完成MySQL数据库的启动以及各项配置;
- 完成MySQL数据库在compute节点的包安装
1、 MySQL基本组件的安装(controller)
[root@controller ~] # yum -y install mysql mysql-server MySQL-python
2、 修改MySQL数据库的配置文件
[root@controller ~] # vi /etc/my.cnf
在[mysqld]添加以下5行配置文件。
bind-address = 192.168.100.10
default-storage-engine = innodb
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
保存退出
bind-address的作用是通过绑定的IP地址来访问数据库;
default-storage-engine的作用是设置数据库的默认存储引擎;
collation-server的作用是设置数据库使用哪种编码方式描述字符的规则并且不区分大小写;
init-connect的作用是设置数据库的存储编码方式为哪种;
character-set-server的作用是设置客户端的字符编码方式为哪种;
3、 启动MySQL数据库
[root@controller ~] # service mysqld restart
设置开机自启
[root@controller ~] # chkconfig mysqld on
4、 对数据库进行配置
4.1 初始化数据库
[root@controller ~] # mysql_install_db
4.2 数据库的安全配置
[root@controller ~] # mysql_secure_installation
按enter确认后设置数据库root密码
Remove anonymous users? [Y/n] y 是否要删除匿名用户
Disallow root login remotely? [Y/n] n 是否不允许root用户远程登录
Remove test database and access to it? [Y/n] y 是否删除“test”数据库
Reload privilege tables now? [Y/n] y 是否现在重载权限表
5、 安装MySQL数据库的python包(compute)
[root@controller ~] # yum -y install MySQL-python
适用于在Linux系统安装MySQL数据库的大致安装方法