MySQL提示启动成功,实际进程并没有起来
Posted leozhanggg
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL提示启动成功,实际进程并没有起来相关的知识,希望对你有一定的参考价值。
一、概括:
1、查看运行日志 vim /var/log/mariadb/mariadb.log
2、修改配置文件 vim /etc/my.cnf
3、修改文件权限 chown mysql.mysql -R /var/lib/mysql/
二、详情:
首先我们尝试启动MySQL,发现没有MySQL进程
[email protected] sbin]# pwd /usr/local/mysql/bin [root@centos74-tmp bin]# service mysqld start Starting MySQL SUCCESS! [root@centos74-tmp bin]# pgrep -af mysql
我们查看日志 mariadb.log,发现缺少数据文件
[[email protected] bin]# vim /var/log/mariadb/mariadb.log 2019-06-15T01:38:41.969191Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-06-15T01:38:41.969334Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2019-06-15T01:38:41.969372Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.22) starting as process 32707 ... 2019-06-15T01:38:41.976201Z 0 [Note] InnoDB: PUNCH HOLE support available 2019-06-15T01:38:41.976243Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2019-06-15T01:38:41.976249Z 0 [Note] InnoDB: Uses event mutexes 2019-06-15T01:38:41.976267Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier 2019-06-15T01:38:41.976272Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2019-06-15T01:38:41.976277Z 0 [Note] InnoDB: Using Linux native AIO 2019-06-15T01:38:41.976564Z 0 [Note] InnoDB: Number of pools: 1 2019-06-15T01:38:41.976689Z 0 [Note] InnoDB: Using CPU crc32 instructions 2019-06-15T01:38:41.978521Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2019-06-15T01:38:41.988017Z 0 [Note] InnoDB: Completed initialization of buffer pool 2019-06-15T01:38:41.991091Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2019-06-15T01:38:42.001066Z 0 [Note] InnoDB: The first innodb_system data file ‘ibdata1‘ did not exist. A new tablespace will be created! 2019-06-15T01:38:42.001400Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation. 2019-06-15T01:38:42.001411Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. 2019-06-15T01:38:42.001417Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation. 2019-06-15T01:38:42.001421Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. 2019-06-15T01:38:42.001427Z 0 [ERROR] InnoDB: Cannot open datafile ‘./ibdata1‘ 2019-06-15T01:38:42.001433Z 0 [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! 2019-06-15T01:38:42.001439Z 0 [ERROR] InnoDB: InnoDB Database creation was aborted with error Cannot open a file. You may need to delete the ibdata1 file before trying to start up again. 2019-06-15T01:38:42.602600Z 0 [ERROR] Plugin ‘InnoDB‘ init function returned error. 2019-06-15T01:38:42.602658Z 0 [ERROR] Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed. 2019-06-15T01:38:42.602666Z 0 [ERROR] Failed to initialize builtin plugins. 2019-06-15T01:38:42.602670Z 0 [ERROR] Aborting 2019-06-15T01:38:42.602679Z 0 [Note] Binlog end 2019-06-15T01:38:42.603033Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
通过配置文件 my.cnf 查看数据文件 ibdata1 路径 ,发现实际文件不在
[[email protected] mysql]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock
[[email protected] mysql]# cd /var/lib/mysql/data/ibdata1
-bash: cd: /var/lib/mysql/data/ibdata1: No such file or directory
通过 find 命令找到数据文件 ibdata1 实际目录,并修改配置文件 my.cnf
[[email protected] mysql]# find / -name ibdata* /usr/local/mysql/data/ibdata1 [root@centos74-tmp mysql]# vim /etc/my.cnf [mysqld] datadir=/usr/local/mysql/data/ socket=/var/lib/mysql/mysql.sock
再次尝试启动MySQL,发现端口一会就没了
[[email protected] mysql]# service mysqld start Starting MySQL SUCCESS! [root@centos74-tmp bin]# netstat -lnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN tcp6 0 0 :::3306 :::* LISTEN tcp6 0 0 :::4118 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN [root@centos74-tmp bin]# netstat -lnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN tcp6 0 0 :::4118 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN
再次查看MySQL日志,发现不能创建 mysql.sock.lock 文件
2019-06-15T01:49:41.178424Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-06-15T01:49:41.178562Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2019-06-15T01:49:41.178599Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.22) starting as process 2650 ... 2019-06-15T01:49:41.184805Z 0 [Note] InnoDB: PUNCH HOLE support available 2019-06-15T01:49:41.184848Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2019-06-15T01:49:41.184854Z 0 [Note] InnoDB: Uses event mutexes 2019-06-15T01:49:41.184860Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier 2019-06-15T01:49:41.184864Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2019-06-15T01:49:41.184869Z 0 [Note] InnoDB: Using Linux native AIO 2019-06-15T01:49:41.185282Z 0 [Note] InnoDB: Number of pools: 1 2019-06-15T01:49:41.185458Z 0 [Note] InnoDB: Using CPU crc32 instructions 2019-06-15T01:49:41.187568Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2019-06-15T01:49:41.197993Z 0 [Note] InnoDB: Completed initialization of buffer pool 2019-06-15T01:49:41.202453Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2019-06-15T01:49:41.330706Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2019-06-15T01:49:41.338353Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 360871592 2019-06-15T01:49:41.338438Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 360871601 2019-06-15T01:49:41.338470Z 0 [Note] InnoDB: Database was not shutdown normally! 2019-06-15T01:49:41.338490Z 0 [Note] InnoDB: Starting crash recovery. 2019-06-15T01:49:43.702763Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2019-06-15T01:49:43.702868Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2019-06-15T01:49:43.702998Z 0 [Note] InnoDB: Setting file ‘./ibtmp1‘ size to 12 MB. Physically writing the file full; Please wait ... 2019-06-15T01:49:43.831707Z 0 [Note] InnoDB: File ‘./ibtmp1‘ size is now 12 MB. 2019-06-15T01:49:43.836313Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2019-06-15T01:49:43.836353Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2019-06-15T01:49:43.838015Z 0 [Note] InnoDB: Waiting for purge to start 2019-06-15T01:49:43.888404Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 360871601 2019-06-15T01:49:43.890016Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql/data/ib_buffer_pool 2019-06-15T01:49:43.916045Z 0 [Note] Plugin ‘FEDERATED‘ is disabled. 2019-06-15T01:49:43.964452Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190615 9:49:43 2019-06-15T01:49:44.009629Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2019-06-15T01:49:44.009838Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL_CTX_set_default_verify_paths failed 2019-06-15T01:49:44.010380Z 0 [Note] Server hostname (bind-address): ‘*‘; port: 3306 2019-06-15T01:49:44.010529Z 0 [Note] IPv6 is available. 2019-06-15T01:49:44.010552Z 0 [Note] - ‘::‘ resolves to ‘::‘; 2019-06-15T01:49:44.010588Z 0 [Note] Server socket created on IP: ‘::‘. 2019-06-15T01:49:44.010733Z 0 [ERROR] Could not create unix socket lock file /var/lib/mysql/mysql.sock.lock. 2019-06-15T01:49:44.010746Z 0 [ERROR] Unable to setup unix socket lock file. 2019-06-15T01:49:44.010755Z 0 [ERROR] Aborting
查看文件夹权限,发现属主为root,修改为mysql
[[email protected] mysql]# ll /var/lib/ total 4 …… drwxr-xr-x 2 root root 6 Jun 15 09:44 mysql …… [root@centos74-tmp mysql]# chown mysql.mysql -R /var/lib/mysql/ [[email protected] mysql]# ll /var/lib/ total 4 …… drwxr-xr-x 2 mysql mysql 47 Jun 15 09:53 mysql ……
再次尝试重启MySQL,发现启动成功!!!
[[email protected] mysql]# service mysqld start service mysqld start Starting MySQL. SUCCESS! [root@centos74-tmp mysql]# netstat -lnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN tcp6 0 0 :::3306 :::* LISTEN tcp6 0 0 :::4118 :::* LISTEN tcp6 0 0 :::22
[[email protected] mysql]# vim /var/log/mariadb/mariadb.log
2019-06-15T01:49:44.010780Z 0 [Note] Binlog end 2019-06-15T01:49:44.010938Z 0 [Note] Shutting down plugin ‘ngram‘ 2019-06-15T01:49:44.010973Z 0 [Note] Shutting down plugin ‘ARCHIVE‘ 2019-06-15T01:49:44.010984Z 0 [Note] Shutting down plugin ‘partition‘ 2019-06-15T01:49:44.010992Z 0 [Note] Shutting down plugin ‘BLACKHOLE‘ 2019-06-15T01:49:44.011002Z 0 [Note] Shutting down plugin ‘PERFORMANCE_SCHEMA‘ 2019-06-15T01:49:44.011161Z 0 [Note] Shutting down plugin ‘CSV‘ 2019-06-15T01:49:44.011175Z 0 [Note] Shutting down plugin ‘MEMORY‘ 2019-06-15T01:49:44.011196Z 0 [Note] Shutting down plugin ‘MRG_MYISAM‘ 2019-06-15T01:49:44.011216Z 0 [Note] Shutting down plugin ‘MyISAM‘ 2019-06-15T01:49:44.011786Z 0 [Note] Shutting down plugin ‘INNODB_SYS_VIRTUAL‘ 2019-06-15T01:49:44.011817Z 0 [Note] Shutting down plugin ‘INNODB_SYS_DATAFILES‘ 2019-06-15T01:49:44.011833Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESPACES‘ 2019-06-15T01:49:44.011838Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN_COLS‘ 2019-06-15T01:49:44.011842Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN‘ 2019-06-15T01:49:44.011846Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FIELDS‘ 2019-06-15T01:49:44.011851Z 0 [Note] Shutting down plugin ‘INNODB_SYS_COLUMNS‘ 2019-06-15T01:49:44.011855Z 0 [Note] Shutting down plugin ‘INNODB_SYS_INDEXES‘ 2019-06-15T01:49:44.011859Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESTATS‘ 2019-06-15T01:49:44.011864Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLES‘ 2019-06-15T01:49:44.011868Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_TABLE‘ 2019-06-15T01:49:44.011872Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_CACHE‘ 2019-06-15T01:49:44.011876Z 0 [Note] Shutting down plugin ‘INNODB_FT_CONFIG‘ 2019-06-15T01:49:44.011880Z 0 [Note] Shutting down plugin ‘INNODB_FT_BEING_DELETED‘ 2019-06-15T01:49:44.011885Z 0 [Note] Shutting down plugin ‘INNODB_FT_DELETED‘ 2019-06-15T01:49:44.011889Z 0 [Note] Shutting down plugin ‘INNODB_FT_DEFAULT_STOPWORD‘ 2019-06-15T01:49:44.011893Z 0 [Note] Shutting down plugin ‘INNODB_METRICS‘ 2019-06-15T01:49:44.011897Z 0 [Note] Shutting down plugin ‘INNODB_TEMP_TABLE_INFO‘ 2019-06-15T01:49:44.011901Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_POOL_STATS‘ 2019-06-15T01:49:44.011906Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE_LRU‘ 2019-06-15T01:49:44.011910Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE‘ 2019-06-15T01:49:44.011914Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX_RESET‘ 2019-06-15T01:49:44.011919Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX‘ 2019-06-15T01:49:44.011923Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM_RESET‘ 2019-06-15T01:49:44.011927Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM‘ 2019-06-15T01:49:44.011947Z 0 [Note] Shutting down plugin ‘INNODB_CMP_RESET‘ 2019-06-15T01:49:44.011952Z 0 [Note] Shutting down plugin ‘INNODB_CMP‘ 2019-06-15T01:49:44.011956Z 0 [Note] Shutting down plugin ‘INNODB_LOCK_WAITS‘ 2019-06-15T01:49:44.011961Z 0 [Note] Shutting down plugin ‘INNODB_LOCKS‘ 2019-06-15T01:49:44.011965Z 0 [Note] Shutting down plugin ‘INNODB_TRX‘ 2019-06-15T01:49:44.011969Z 0 [Note] Shutting down plugin ‘InnoDB‘ 2019-06-15T01:49:44.012134Z 0 [Note] InnoDB: FTS optimize thread exiting. 2019-06-15T01:49:44.012281Z 0 [Note] InnoDB: Starting shutdown... 2019-06-15T01:49:44.112614Z 0 [Note] InnoDB: Dumping buffer pool(s) to /usr/local/mysql/data/ib_buffer_pool 2019-06-15T01:49:44.117111Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 190615 9:49:44 2019-06-15T01:49:45.836575Z 0 [Note] InnoDB: Shutdown completed; log sequence number 360872741 2019-06-15T01:49:45.839893Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2019-06-15T01:49:45.839924Z 0 [Note] Shutting down plugin ‘sha256_password‘ 2019-06-15T01:49:45.839932Z 0 [Note] Shutting down plugin ‘mysql_native_password‘ 2019-06-15T01:49:45.840120Z 0 [Note] Shutting down plugin ‘binlog‘ 2019-06-15T01:49:45.840407Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
—— 以上仅为我个人遇到的情况,可能会有所不同,请根据实际情况,依据日志报错一个个处理。
以上是关于MySQL提示启动成功,实际进程并没有起来的主要内容,如果未能解决你的问题,请参考以下文章
MySQL无法启动mysql服务(位于本地计算机上)错误1067,进程意外中止