to be continued。。。
1、安装
yum installmysql-server安装MySQL。
2、配置
CentOS6的MySQL默认是用MyIsam表引擎的,不支持事务,
建议改为innoDB。修改/etc/my.cnf
[mysqld]
transaction-isolation=READ-COMMITTED
default-storage-engine=InnoDB
datadir=/data/app/mysql
socket=/var/lib/mysql/mysql.sock
# log-bin should be on a disk with enoughfree space
log-bin=/data/app/mysql/mysql_binary_log
# Disabling symbolic-links is recommendedto prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 16M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
# Important: see Configuring the Databasesand Setting max_connections
max_connections = 550
# For MySQL version 5.1.8 or later. Commentout binlog_format for older versions.
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
修改前
修改后
3、启动和初始化
chkconfig mysqld on设置开机启动,并service mysqld start启动mysql服务,并根据提示设置root的初试密码:mysqladmin -u root password 'yourpasswd'。
报错
查看数据库状态
service mysqld status
重启service mysqld restart
查看日志tail -f /var/log/mysqld.log
yum -y remove mysql*
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum clean all
yum makecache
yum -y update
4、创建mysql用户
MySQL默认root用户是不支持运程访问的,如果需要远程访问MySQL建议创建一个非root用户。运行 mysql -uroot –pyourpasswd 进入MySQL数据库。执行下面命令创建用户:
#授权root用户在主节点拥有所有数据库的访问权限
grant all privileges on *.* to 'datahub'@'%'identified by 'cimc1234' with grant option;
flush privileges;
grant all privileges on *.* to 'datahub'@'%'identified by 'datahub!4321';
查看mysql版本