tar -zxvf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.13-linux-glibc2.5-x86_64 mysql
mkdir log tmp var data conf
chown hadoop:hadoop log tmp var data chown -R hadoop data log var tmp
vi /home/hadoop/mysql/conf/my.cnf
[mysqld] log-bin = mysql-bin server-id = 1 user = hadoop port = 3306 key_buffer_size = 256M max_allowed_packet = 256M slave_max_allowed_packet = 256M table_open_cache = 512 sort_buffer_size = 2M net_buffer_length = 8K read_buffer_size = 2M read_rnd_buffer_size = 512K myisam_sort_buffer_size = 64M thread_cache_size = 64 query_cache_size = 64M max_connections = 32000 tmp_table_size = 128M long_query_time = 3 slow_query_log innodb_buffer_pool_size = 7000M #如果机器只有mysql,建议设置为物理内存的75% innodb_flush_log_at_trx_commit = 0 innodb_flush_method = O_DIRECT innodb_file_format = barracuda innodb_log_file_size = 1G innodb_log_files_in_group = 3 character_set_server = utf8 log_timestamps = SYSTEM #have_statement_timeout = NO ############### PATH ############## basedir = /home/hadoop/mysql datadir = /home/hadoop/mysql/data tmpdir = /home/hadoop/mysql/tmp socket = /home/hadoop/mysql/var/mysql.sock pid_file = /home/hadoop/mysql/var/mysql.pid general_log_file = /home/hadoop/mysql/log/general.log innodb_data_home_dir = /home/hadoop/mysql/data slow_query_log_file = /home/hadoop/mysql/log/slow.log log_error = /home/hadoop/mysql/log/error.log sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set = utf8 [client] default-character-set = utf8
bin/mysqld --initialize --basedir=/home/hadoop/mysql/ --datadir=/home/hadoop/mysql/data --user=hadoop --socket=/home/hadoop/mysql/var --port=3306
如果初始化没有打印出日志 查看是否有/etc/my.cnf 默认读取了该配置
初始化后会在控制台打印出初始密码,一般就是最后几个字符,先记录下来。
--basedir 指定mysql安装目录
--datadi 指定data目录
--user 指定用户
--socket 指定socket文件存放位置
--port 指定启动端口
nohup bin/mysqld_safe --defaults-file=/home/hadoop/mysql/conf/my.cnf --socket=/home/hadoop/mysql/var/mysql.sock &
bin/mysql -u root -S /home/hadoop/mysql/var/mysql.sock -p
输入刚才记录的初始密码
set password=password('123456');
ln -s /home/hadoop/mysql/var/mysql.sock /tmp/mysql.sock
export MYSQL_HOME=/home/hadoop/mysql export PATH=$MYSQL_HOME/bin:$PATH
grant all privileges on *.* to root@'%' identified by '123456'; flush privileges;
use mysql; select host,user from user;
cp support-files/mysql.server /etc/init.d/mysql
cp mysql.server /etc/init.d/mysqld cd /etc/init.d/ chkconfig --add mysqld #将mysql加到启动服务列表里
create user 'meta'@'%' identified by 'meta2015';
授予权限
grant all on *.* to meta@'%';