1、把原先安装好的data目录删除掉,或者删除其中内容。再将姜的配置文件上传,修改下innoodb_log_file_size的大小,更改为1G。要不然太大,虚拟机没那么大空间。
上传好后,进行初始化的时候报错,没有生成相应配置文件中的内容,比如undo,redo文件。而且iostat -xm 3来看磁盘并没有写入,说明文件应该没有生成。
1 [root@localhost mysql]# scripts/mysql_install_db --user=mysql 2 Installing MySQL system tables...2020-02-16 22:55:27 0 [Note] ./bin/mysqld (mysqld 5.6.27-log) starting as process 9078 ... 3 [root@localhost mysql]# cd data 4 [root@localhost data]# ls 5 bin.index error.log ibdata1 mysql test 6 [root@localhost data]# ll 7 总用量 12292 8 -rw-rw----. 1 mysql mysql 0 2月 16 22:55 bin.index 9 -rw-rw----. 1 mysql mysql 1890 2月 16 22:55 error.log 10 -rw-rw----. 1 mysql mysql 12582912 2月 16 22:55 ibdata1 11 drwx------. 2 mysql mysql 6 2月 16 22:55 mysql
2、查看错误日志的输出内容
1 [root@localhost data]# less error.log 2 2020-02-16 22:55:27 9078 [Note] InnoDB: Using atomics to ref count buffer pool pages 3 2020-02-16 22:55:27 9078 [Note] InnoDB: The InnoDB memory heap is disabled 4 2020-02-16 22:55:27 9078 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 5 2020-02-16 22:55:27 9078 [Note] InnoDB: Memory barrier is not used 6 2020-02-16 22:55:27 9078 [Note] InnoDB: Compressed tables use zlib 1.2.3 7 2020-02-16 22:55:27 9078 [Note] InnoDB: Using Linux native AIO 8 2020-02-16 22:55:27 9078 [Note] InnoDB: Using CPU crc32 instructions 9 2020-02-16 22:55:27 9078 [Note] InnoDB: Initializing buffer pool, size = 128.0M 10 2020-02-16 22:55:27 9078 [Note] InnoDB: Completed initialization of buffer pool 11 2020-02-16 22:55:27 9078 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 12 2020-02-16 22:55:27 9078 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 13 2020-02-16 22:55:27 9078 [Note] InnoDB: Database physically writes the file full: wait... 14 2020-02-16 22:55:27 7f1748a2d740 InnoDB: Operating system error number 2 in a file operation. 15 InnoDB: The error means the system cannot find the path specified. 16 InnoDB: If you are installing InnoDB, remember that you must create 17 InnoDB: directories yourself, InnoDB does not create them. 18 2020-02-16 22:55:27 9078 [ERROR] InnoDB: File /redolog/ib_logfile101: 'create' returned OS error 71. 19 2020-02-16 22:55:27 9078 [ERROR] InnoDB: Cannot create /redolog/ib_logfile101 20 2020-02-16 22:55:27 9078 [ERROR] Plugin 'InnoDB' init function returned error. 21 2020-02-16 22:55:27 9078 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 22 2020-02-16 22:55:27 9078 [ERROR] Unknown/unsupported storage engine: InnoDB 23 2020-02-16 22:55:27 9078 [ERROR] Aborting 24 25 2020-02-16 22:55:27 9078 [Note] Binlog end 26 2020-02-16 22:55:27 9078 [Note] unregister_replicator OK 27 2020-02-16 22:55:27 9078 [Note] ./bin/mysqld: Shutdown complete
不太清楚是什么错误,把配置文件的路径信息先注释掉试试。
3、再次修改配置文件内容
1 [root@localhost data]# vi /etc/my.cnf 2 [client] 3 user=root 4 password=111111 5 6 [mysqld] 7 ########basic settings######## 8 server-id = 11 9 port = 3306 10 user = mysql 11 #bind_address = 10.166.224.32 12 #autocommit = 0 13 character_set_server=utf8mb4 14 skip_name_resolve = 1 15 max_connections = 800 16 max_connect_errors = 1000 17 #datadir = /data/mysql_data 18 datadir = /usr/local/mysql/data 19 transaction_isolation = READ-COMMITTED 20 explicit_defaults_for_timestamp = 1 21 join_buffer_size = 134217728 22 tmp_table_size = 67108864 23 tmpdir = /tmp 24 max_allowed_packet = 16777216 25 #sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER" 26 interactive_timeout = 1800 27 wait_timeout = 1800 28 read_buffer_size = 16777216 29 read_rnd_buffer_size = 33554432 30 sort_buffer_size = 33554432 31 ########log settings######## 32 log_error = error.log 33 #slow_query_log = 1 34 #slow_query_log_file = slow.log 35 #log_queries_not_using_indexes = 1 36 #log_slow_admin_statements = 1 37 #log_slow_slave_statements = 1 38 #log_throttle_queries_not_using_indexes = 10 39 #expire_logs_days = 90 40 #long_query_time = 2 41 #min_examined_row_limit = 100 42 ########replication settings######## 43 #master_info_repository = TABLE 44 #relay_log_info_repository = TABLE 45 log_bin = bin.log 46 #sync_binlog = 1 47 #gtid_mode = on 48 #enforce_gtid_consistency = 1 49 #log_slave_updates 50 #binlog_format = row 51 #relay_log = relay.log 52 #relay_log_recovery = 1 53 #binlog_gtid_simple_recovery = 1 54 #slave_skip_errors = ddl_exist_errors 55 ########innodb settings######## 56 #innodb_page_size = 8192 57 #innodb_buffer_pool_size = 6G 58 #innodb_buffer_pool_instances = 8 59 #innodb_buffer_pool_load_at_startup = 1 60 #innodb_buffer_pool_dump_at_shutdown = 1 61 #innodb_lru_scan_depth = 2000 62 #innodb_lock_wait_timeout = 5 63 #innodb_io_capacity = 4000 64 #innodb_io_capacity_max = 8000 65 #innodb_flush_method = O_DIRECT 66 #innodb_file_format = Barracuda 67 #innodb_file_format_max = Barracuda 68 #innodb_log_group_home_dir = /redolog/ 69 #innodb_undo_directory = /undolog/ 70 innodb_undo_logs = 128 71 innodb_undo_tablespaces = 3 72 #innodb_flush_neighbors = 1 73 innodb_log_file_size = 1G 74 innodb_log_buffer_size = 16777216 75 #innodb_purge_threads = 4 76 #innodb_large_prefix = 1 77 #innodb_thread_concurrency = 64 78 #innodb_print_all_deadlocks = 1 79 #innodb_strict_mode = 1 80 innodb_sort_buffer_size = 67108864 81 ########semi sync replication settings######## 82 plugin_dir=/usr/local/mysql/lib/plugin 83 plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so" 84 #loose_rpl_semi_sync_master_enabled = 1 85 #loose_rpl_semi_sync_slave_enabled = 1 86 #loose_rpl_semi_sync_master_timeout = 5000 87 88 [mysqld-5.7] 89 innodb_buffer_pool_dump_pct = 40 90 "/etc/my.cnf" [dos] 96L, 2926C written
注释掉68、69条后,再删除data后,初始化操作。
1 [root@localhost mysql]# scripts/mysql_install_db --user=mysql 2 Installing MySQL system tables...2020-02-16 23:00:14 0 [Note] ./bin/mysqld (mysqld 5.6.27-log) starting as process 9162 ... 3 OK 4 5 Filling help tables...2020-02-16 23:01:16 0 [Note] ./bin/mysqld (mysqld 5.6.27-log) starting as process 9201 ... 6 OK 7 8 To start mysqld at boot time you have to copy 9 support-files/mysql.server to the right place for your system 10 11 PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! 12 To do so, start the server, then issue the following commands: 13 14 ./bin/mysqladmin -u root password 'new-password' 15 ./bin/mysqladmin -u root -h localhost.localdomain password 'new-password' 16 17 Alternatively you can run: 18 19 ./bin/mysql_secure_installation 20 21 which will also give you the option of removing the test 22 databases and anonymous user created by default. This is 23 strongly recommended for production servers. 24 25 See the manual for more instructions. 26 27 You can start the MySQL daemon with: 28 29 cd . ; ./bin/mysqld_safe & 30 31 You can test the MySQL daemon with mysql-test-run.pl 32 33 cd mysql-test ; perl mysql-test-run.pl 34 35 Please report any problems at http://bugs.mysql.com/ 36 37 The latest information about MySQL is available on the web at 38 39 http://www.mysql.com 40 41 Support MySQL by buying support/licenses at http://shop.mysql.com 42 43 WARNING: Found existing config file ./my.cnf on the system. 44 Because this file might be in use, it was not replaced, 45 but was used in bootstrap (unless you used --defaults-file) 46 and when you later start the server. 47 The new default config file was created as ./my-new.cnf, 48 please compare it with your file and take the changes you need. 49 50 WARNING: Default config file /etc/my.cnf exists on the system 51 This file will be read by default by the MySQL server 52 If you do not want to use this, either remove it, or use the 53 --defaults-file argument to mysqld_safe when starting the server
43行内容就是个小错误,但是没有报error,只报了一个warning。
这个错误应该是检测到还有其它的my.cnf,按理说不应该,因为/etc/下的各版本的my.cnf都已经改了后缀名,应该不会出这个错误。不懂。
5、再次查看新生成的error.log中输出 的内容
1 [root@localhost mysql]# cat data/error.log 2 2020-02-16 23:00:14 9162 [Note] InnoDB: Using atomics to ref count buffer pool pages 3 2020-02-16 23:00:14 9162 [Note] InnoDB: The InnoDB memory heap is disabled 4 2020-02-16 23:00:14 9162 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 5 2020-02-16 23:00:14 9162 [Note] InnoDB: Memory barrier is not used 6 2020-02-16 23:00:14 9162 [Note] InnoDB: Compressed tables use zlib 1.2.3 7 2020-02-16 23:00:14 9162 [Note] InnoDB: Using Linux native AIO 8 2020-02-16 23:00:14 9162 [Note] InnoDB: Using CPU crc32 instructions 9 2020-02-16 23:00:14 9162 [Note] InnoDB: Initializing buffer pool, size = 128.0M 10 2020-02-16 23:00:14 9162 [Note] InnoDB: Completed initialization of buffer pool 11 2020-02-16 23:00:14 9162 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 12 2020-02-16 23:00:14 9162 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 13 2020-02-16 23:00:14 9162 [Note] InnoDB: Database physically writes the file full: wait... 14 2020-02-16 23:00:14 9162 [Note] InnoDB: Setting log file ./ib_logfile101 size to 1024 MB 15 InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 16 2020-02-16 23:00:41 9162 [Note] InnoDB: Setting log file ./ib_logfile1 size to 1024 MB 17 InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 18 2020-02-16 23:01:13 9162 [Note] InnoDB: Data file ./undo001 did not exist: new to be created 19 2020-02-16 23:01:13 9162 [Note] InnoDB: Setting file ./undo001 size to 10 MB 20 2020-02-16 23:01:13 9162 [Note] InnoDB: Database physically writes the file full: wait... 21 2020-02-16 23:01:13 9162 [Note] InnoDB: Data file ./undo002 did not exist: new to be created 22 2020-02-16 23:01:13 9162 [Note] InnoDB: Setting file ./undo002 size to 10 MB 23 2020-02-16 23:01:13 9162 [Note] InnoDB: Database physically writes the file full: wait... 24 2020-02-16 23:01:13 9162 [Note] InnoDB: Data file ./undo003 did not exist: new to be created 25 2020-02-16 23:01:13 9162 [Note] InnoDB: Setting file ./undo003 size to 10 MB 26 2020-02-16 23:01:13 9162 [Note] InnoDB: Database physically writes the file full: wait... 27 2020-02-16 23:01:13 9162 [Note] InnoDB: Opened 3 undo tablespaces 28 2020-02-16 23:01:13 9162 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 29 2020-02-16 23:01:13 9162 [Warning] InnoDB: New log files created, LSN=48424 30 2020-02-16 23:01:13 9162 [Note] InnoDB: Doublewrite buffer not found: creating new 31 2020-02-16 23:01:13 9162 [Note] InnoDB: Doublewrite buffer created 32 2020-02-16 23:01:13 9162 [Note] InnoDB: 128 rollback segment(s) are active. 33 2020-02-16 23:01:13 9162 [Warning] InnoDB: Creating foreign key constraint system tables. 34 2020-02-16 23:01:13 9162 [Note] InnoDB: Foreign key constraint system tables created 35 2020-02-16 23:01:13 9162 [Note] InnoDB: Creating tablespace and datafile system tables. 36 2020-02-16 23:01:13 9162 [Note] InnoDB: Tablespace and datafile system tables created. 37 2020-02-16 23:01:13 9162 [Note] InnoDB: Waiting for purge to start 38 2020-02-16 23:01:13 9162 [Note] InnoDB: 5.6.27 started; log sequence number 0 39 2020-02-16 23:01:14 9162 [Note] Binlog end 40 2020-02-16 23:01:14 9162 [Note] unregister_replicator OK 41 2020-02-16 23:01:14 9162 [Note] InnoDB: FTS optimize thread exiting. 42 2020-02-16 23:01:14 9162 [Note] InnoDB: Starting shutdown... 43 2020-02-16 23:01:15 9162 [Note] InnoDB: Shutdown completed; log sequence number 1508991 44 2020-02-16 23:01:16 9201 [Note] InnoDB: Using atomics to ref count buffer pool pages 45 2020-02-16 23:01:16 9201 [Note] InnoDB: The InnoDB memory heap is disabled 46 2020-02-16 23:01:16 9201 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 47 2020-02-16 23:01:16 9201 [Note] InnoDB: Memory barrier is not used 48 2020-02-16 23:01:16 9201 [Note] InnoDB: Compressed tables use zlib 1.2.3 49 2020-02-16 23:01:16 9201 [Note] InnoDB: Using Linux native AIO 50 2020-02-16 23:01:16 9201 [Note] InnoDB: Using CPU crc32 instructions 51 2020-02-16 23:01:16 9201 [Note] InnoDB: Initializing buffer pool, size = 128.0M 52 2020-02-16 23:01:16 9201 [Note] InnoDB: Completed initialization of buffer pool 53 2020-02-16 23:01:16 9201 [Note] InnoDB: Opened 3 undo tablespaces 54 2020-02-16 23:01:16 9201 [Note] InnoDB: Highest supported file format is Barracuda. 55 2020-02-16 23:01:16 9201 [Note] InnoDB: 128 rollback segment(s) are active. 56 2020-02-16 23:01:16 9201 [Note] InnoDB: Waiting for purge to start 57 2020-02-16 23:01:16 9201 [Note] InnoDB: 5.6.27 started; log sequence number 1508991 58 2020-02-16 23:01:16 9201 [Note] Binlog end 59 2020-02-16 23:01:16 9201 [Note] unregister_replicator OK 60 2020-02-16 23:01:16 9201 [Note] InnoDB: FTS optimize thread exiting. 61 2020-02-16 23:01:16 9201 [Note] InnoDB: Starting shutdown... 62 2020-02-16 23:01:17 9201 [Note] InnoDB: Shutdown completed; log sequence number 1509001
现在可以看到没有报错信息了!
6、此时Mysql命令还不能用,因为mysql 的bin目录还没有配置到环境变更 中,具体看以下内容:
1 [root@localhost mysql]# mysql 2 -bash: mysql: 未找到命令 3 [root@localhost mysql]# mysqld 4 -bash: mysqld: 未找到命令 ----可以看到此时还不能使用mysql 命令 5 [root@localhost mysql]# export PATH=/usr/local/mysql/bin:$PATH ----这是临时修改的环境变更 ,可以生效一次,永久解决这个问题,需要如下边编辑/etc/profile 6 [root@localhost mysql]# echo $PATH 7 /usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin 8 [root@localhost mysql]# vi /etc/profile 9 profile profile.d/ 10 [root@localhost mysql]# vi /etc/profile 11 profile profile.d/ 12 [root@localhost mysql]# vi /etc/profile 13 # /etc/profile 14 15 # System wide environment and startup programs, for login setup 16 # Functions and aliases go in /etc/bashrc 17 18 # It's NOT a good idea to change this file unless you know what you 19 # are doing. It's much better to create a custom.sh shell script in 20 # /etc/profile.d/ to make custom changes to your environment, as this 21 # will prevent the need for merging in future updates. 22 23 pathmunge () { 24 case ":${PATH}:" in 25 *:"$1":*) 26 ;; 27 *) 28 if [ "$2" = "after" ] ; then 29 PATH=$PATH:$1 30 else 31 PATH=$1:$PATH 32 fi 33 esac 34 } 35 36 37 if [ -x /usr/bin/id ]; then 38 if [ -z "$EUID" ]; then 39 # ksh workaround 40 EUID=`/usr/bin/id -u` 41 UID=`/usr/bin/id -ru` 42 fi 43 USER="`/usr/bin/id -un`" 44 LOGNAME=$USER 45 MAIL="/var/spool/mail/$USER" 46 fi 47 48 # Path manipulation 49 if [ "$EUID" = "0" ]; then 50 pathmunge /usr/sbin 51 pathmunge /usr/local/sbin 52 else 53 pathmunge /usr/local/sbin after 54 pathmunge /usr/sbin after 55 fi 56 57 HOSTNAME=`/usr/bin/hostname 2>/dev/null` 58 HISTSIZE=1000 59 if [ "$HISTCONTROL" = "ignorespace" ] ; then 60 export HISTCONTROL=ignoreboth 61 else 62 export HISTCONTROL=ignoredups 63 fi 64 65 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL 66 67 # By default, we want umask to get set. This sets it for login shell 68 # Current threshold for system reserved uid/gids is 200 69 # You could check uidgid reservation validity in 70 # /usr/share/doc/setup-*/uidgid file 71 if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then 72 umask 002 73 else 74 umask 022 75 fi 76 77 for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do 78 if [ -r "$i" ]; then 79 if [ "${-#*i}" != "$-" ]; then 80 . "$i" 81 else 82 . "$i" >/dev/null 83 fi 84 fi 85 done 86 87 unset i 88 unset -f pathmunge 89 export PATH=/usr/local/mysql/bin:$PATH ---姜说:路径要在$PATH的前面,不然会报错 90 "/etc/profile" 77L, 1858C written 91 [root@localhost mysql]# ./etc/profile 92 -bash: ./etc/profile: 没有那个文件或目录 93 [root@localhost mysql]# cd / 94 [root@localhost /]# ./etc/profile 95 -bash: ./etc/profile: 权限不够 96 [root@localhost /]# source /etc/profile 97 [root@localhost /]# mysql -V 98 mysql Ver 14.14 Distrib 5.6.27, for linux-glibc2.5 (x86_64) using EditLine wrapper 99 [root@localhost /]# mysql 100 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) --有这一行说明mysql命令已经可以使用了 101 [root@localhost /]#
现在启动和登录进,应该还会报sock文件错误。先不管了,和视频走,升5.7