配置my.cnfmysql
cd /usr/local/mysql/support-files cp my-default.cnf /etc/my.cnf vim /etc/my.cnf ===================================== [client] #password = your_password port = 3306 socket = /data/mysql_data/run/mysql.sock default-character-set=utf8 [mysqld] port = 3306 socket = /data/mysql_data/run/mysql.sock basedir = /usr/local/mysql datadir = /data/mysql_data skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M default-storage-engine = InnoDB character_set_server = utf8 tmpdir = /data/mysql_data/tmp/ log-bin=/data/mysql_data/logs/mysql-bin expire_logs_days= 14 binlog_format=mixed log-error = /data/mysql_data/logs/error.log slow-query-log = 1 long_query_time= 3 slow_query_log_file = /data/mysql_data/logs/slow.log server-id = 1 innodb_data_home_dir = /data/mysql_data/data innodb_data_file_path = ibdata1:10M:autoextend innodb_log_group_home_dir = /data/mysql_data/logs innodb_buffer_pool_size = 16M innodb_additional_mem_pool_size = 2M innodb_log_file_size = 5M innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50 innodb_file_per_table = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout ======================================
2.初始化MYSQL配置表sql
cd /usr/local/mysql ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_data/data --user=mysql --force Installing MySQL system tables...2015-07-30 18:09:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2015-07-30 18:09:19 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.25-73.1-log) starting as process 8165 ...
3.設置開機自啓動shell
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql chkconfig --add mysql chkconfig --level 345 mysql on
4.設置環境變量,方便使用mysql命令vim
vim /etc/profile 在末尾加入: PATH=/usr/local/mysql/bin:$PATH export PATH 保存退出後執行: . /etc/profile 或者 source /etc/profile
5.啓動mysql,設置root密碼socket
service mysql start mysqladmin -uroot password '******'