一、概括:
1、查看运行日志vim /var/log/mariadb/mariadb.log
2、修改配置文件vim /etc/my.cnf
3、修改文件权限 chown mysql.mysql -R /var/lib/mysql/
二、详情:
首先我们尝试启动MySQL,发现没有MySQL进程
root@centos74-tmp 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,发现缺少数据文件
[root@centos74-tmp bin]# vim /var/log/mariadb/mariadb.log2019-06-15T01:38:41.969191Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).2019-06-15T01:38:41.969334Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing andexporting data are disabled2019-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 available2019-06-15T01:38:41.976243Z 0 [Note] InnoDB: Mutexes and rw_locks useGCC atomic builtins2019-06-15T01:38:41.976249Z 0 [Note] InnoDB: Uses eventmutexes2019-06-15T01:38:41.976267Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used formemory barrier2019-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 AIO2019-06-15T01:38:41.976564Z 0 [Note] InnoDB: Number of pools: 1
2019-06-15T01:38:41.976689Z 0[Note] InnoDB: Using CPU crc32 instructions2019-06-15T01:38:41.978521Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size =128M2019-06-15T01:38:41.988017Z 0[Note] InnoDB: Completed initialization of buffer pool2019-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 13in a file operation.2019-06-15T01:38:42.001411Z 0 [ERROR] InnoDB: The error means mysqld does nothave the access rights to the directory.2019-06-15T01:38:42.001417Z 0 [ERROR] InnoDB: Operating system error number 13in a file operation.2019-06-15T01:38:42.001421Z 0 [ERROR] InnoDB: The error means mysqld does nothave 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,