二進制安裝MySQL 5.6mysql
yum -y install libaio-devel useradd mysql -s /sbin/nologin -M mkdir /data/mysql/{data,tmp,binlog,log} -p chown -R mysql.mysql /data/mysql tar -xf mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ cd /usr/local/ mv mysql-5.6.20-linux-glibc2.5-x86_64 mysql chown -R mysql.mysql /usr/local/mysql cd /usr/local/mysql/scripts ./mysql_install_db --datadir=/data/mysql/data --basedir=/usr/local/mysql --user=mysql --explicit_defaults_for_timestamp cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld echo "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh source /etc/profile chkconfig mysqld on /etc/init.d/mysqld restart ps -ef|grep mysql
###啓動MySQL是報錯linux
Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql/localhost.pid).sql
查看mysql的日誌數據庫
[ERROR] InnoDB: auto-extending data file /data/mysql/data/ibdata1 is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 32000 pages, max 0 (relevant if non-zero) pages! [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data! [ERROR] Plugin 'InnoDB' init function returned error. [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. [ERROR] Unknown/unsupported storage engine: InnoDB [ERROR] Aborting
解決方法:bash
執行刪除命令:rm -rf /data/mysql/data/ib*dom
刪除:ibdata一、ib_logfile0、ib_logfile1文件socket
從新啓動:service mysqld startide
#刪除測試庫測試
#mysqlui
mysql> show databases ; mysql> drop database test;
#刪除一些沒有用的用戶
mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user; mysql> drop user 'root'@'::1'; mysql> drop user ''@'localhost'; mysql> drop user ''@'localhost.localdomain'; mysql> drop user 'root'@'localhost.localdomain';
#設置數據庫登陸密碼
grant all privileges on *.* to 'root'@'localhost' identified by 'new_pass' with grant option; grant all privileges on *.* to 'root'@'127.0.0.1' identified by 'new_pass' with grant option; flush privileges;
#配置文件
#my.cnf
[mysqld] back_log = 2000 basedir = /usr/local/mysql binlog-format = MIXED character_set_server = utf8 datadir = /data/mysql/data event_scheduler = ON expire_logs_days = 1 innodb_autoinc_lock_mode = 1 innodb_buffer_pool_size = 1073741824 innodb_data_file_path = ibdata1:500M:autoextend innodb_data_home_dir = /data/mysql/data innodb_file_per_table = 1 innodb_flush_log_at_trx_commit = 2 innodb_flush_method = O_DIRECT innodb_io_capacity = 2000 innodb_log_buffer_size = 8388608 innodb_log_files_in_group = 3 innodb_log_group_home_dir = /data/mysql/data innodb_max_dirty_pages_pct = 50 innodb_open_files = 1024 innodb_read_io_threads = 8 innodb_thread_concurrency = 20 innodb_write_io_threads = 8 innodb_lock_wait_timeout = 10 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 key_buffer_size = 3221225472 innodb_log_file_size = 1G local_infile = 1 log-bin = /data/mysql/binlog/mysql-bin.log log_bin_trust_function_creators = 1 log_output = FILE long_query_time = 1 log-error = /data/mysql/log/error.log max_allowed_packet = 134217728 max_connect_errors = 1000000 max_connections = 2000 myisam_sort_buffer_size = 33554432 myisam_recover = 1 join_buffer_size = 8388608 tmp_table_size = 33554432 net_buffer_length = 8192 performance_schema = 1 performance_schema_max_table_instances = 200 pid-file = /data/mysql/mysqld.pid port = 3306 query_cache_size = 0 query_cache_type = 0 read_buffer_size = 20971520 read_rnd_buffer_size = 16M max_heap_table_size = 33554432 bulk_insert_buffer_size = 134217728 #relay-log = /data/mysql/log/mysql-relay.log secure-file-priv = /data/mysql/tmp server-id = 1131053306 skip-slave-start skip_name_resolve slave-load-tmpdir = /data/mysql/tmp slow-query-log-file = /data/mysql/log/mysql-slow.log slow_query_log = 1 socket = /tmp/mysql.sock sort_buffer_size = 2097152 table_open_cache = 128 thread_cache_size = 50 tmpdir = /data/mysql/tmp user = mysql wait_timeout = 2880000 transaction_isolation=read-committed long_query_time=1 sync_binlog=0 innodb_flush_log_at_trx_commit=0 [mysqld_safe] log-error = /data/mysql/log/error.log pid-file = /data/mysql/mysqld.pid