[root@k8s-master ~]# service mysqld start
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
cat /etc/my.cnf
查看配置文件,日志文件路径:/var/log/mysqld.log
[root@k8s-master ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#skip-grant-tables
cat /var/log/mysqld.log
查看日志文件
2022-09-04T11:33:55.617350Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-09-04T11:33:55.619286Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.17) starting as process 19642 ...
2022-09-04T11:33:55.624225Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-09-04T11:33:55.624297Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-09-04T11:33:55.624309Z 0 [Note] InnoDB: Uses event mutexes
2022-09-04T11:33:55.624315Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2022-09-04T11:33:55.624324Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2022-09-04T11:33:55.624332Z 0 [Note] InnoDB: Using Linux native AIO
2022-09-04T11:33:55.624639Z 0 [Note] InnoDB: Number of pools: 1
2022-09-04T11:33:55.624842Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-09-04T11:33:55.627378Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-09-04T11:33:55.647120Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-09-04T11:33:55.651488Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-09-04T11:33:55.667584Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-09-04T11:33:55.669329Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 3769779581
2022-09-04T11:33:55.812871Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775022080
2022-09-04T11:33:55.820068Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263890
2022-09-04T11:33:55.993003Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3774759936
2022-09-04T11:33:56.006272Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263890
2022-09-04T11:33:56.009038Z 0 [Note] InnoDB: Database was not shutdown normally!
2022-09-04T11:33:56.009066Z 0 [Note] InnoDB: Starting crash recovery.
2022-09-04T11:33:56.020807Z 0 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
2022-09-04T11:33:56.536051Z 0 [Note] InnoDB: Apply batch completed
2022-09-04T11:33:56.640659Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-09-04T11:33:56.640726Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-09-04T11:33:56.640866Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-09-04T11:33:56.939236Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-09-04T11:33:56.940164Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-09-04T11:33:56.940185Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-09-04T11:33:56.941182Z 0 [Note] InnoDB: Waiting for purge to start
2022-09-04T11:33:56.991427Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 3775263890
2022-09-04T11:33:56.992055Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-09-04T11:33:56.992398Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-09-04T11:33:56.993483Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220904 19:33:56
2022-09-04T11:33:56.997844Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-09-04T11:33:56.998249Z 0 [Warning] CA certificate ca.pem is self signed.
2022-09-04T11:33:57.000980Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2022-09-04T11:33:57.001034Z 0 [Note] IPv6 is available.
2022-09-04T11:33:57.001047Z 0 [Note] - '::' resolves to '::';
2022-09-04T11:33:57.001071Z 0 [Note] Server socket created on IP: '::'.
2022-09-04T11:33:57.022718Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2022-09-04T11:33:57.022753Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory
2022-09-04T11:38:10.362882Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-09-04T11:38:10.364829Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.17) starting as process 20409 ...
2022-09-04T11:38:10.369686Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-09-04T11:38:10.369741Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-09-04T11:38:10.369749Z 0 [Note] InnoDB: Uses event mutexes
2022-09-04T11:38:10.369754Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2022-09-04T11:38:10.369758Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2022-09-04T11:38:10.369765Z 0 [Note] InnoDB: Using Linux native AIO
2022-09-04T11:38:10.370094Z 0 [Note] InnoDB: Number of pools: 1
2022-09-04T11:38:10.370214Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-09-04T11:38:10.372292Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-09-04T11:38:10.381280Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-09-04T11:38:10.384049Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-09-04T11:38:10.397180Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-09-04T11:38:10.398706Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 3769779581
2022-09-04T11:38:10.528267Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775022080
2022-09-04T11:38:10.535658Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263931
2022-09-04T11:38:10.660751Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3774759936
2022-09-04T11:38:10.675574Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263931
2022-09-04T11:38:10.678263Z 0 [Note] InnoDB: Database was not shutdown normally!
2022-09-04T11:38:10.678290Z 0 [Note] InnoDB: Starting crash recovery.
2022-09-04T11:38:10.696002Z 0 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
2022-09-04T11:38:11.225512Z 0 [Note] InnoDB: Apply batch completed
2022-09-04T11:38:11.330737Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-09-04T11:38:11.330800Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-09-04T11:38:11.330881Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-09-04T11:38:11.346434Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-09-04T11:38:11.347306Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-09-04T11:38:11.347327Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-09-04T11:38:11.357178Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 3775263931
2022-09-04T11:38:11.357473Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-09-04T11:38:11.379327Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-09-04T11:38:11.381859Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220904 19:38:11
2022-09-04T11:38:11.387283Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-09-04T11:38:11.387787Z 0 [Warning] CA certificate ca.pem is self signed.
2022-09-04T11:38:11.390931Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2022-09-04T11:38:11.391017Z 0 [Note] IPv6 is available.
2022-09-04T11:38:11.391039Z 0 [Note] - '::' resolves to '::';
2022-09-04T11:38:11.391064Z 0 [Note] Server socket created on IP: '::'.
2022-09-04T11:38:11.395498Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)
2022-09-04T11:38:11.395546Z 0 [ERROR] Can't start server: can't create PID file: Permission denied
处理:
[root@k8s-master ~]#
[root@k8s-master ~]# cd /var/run
[root@k8s-master run]#
[root@k8s-master run]# mkdir mysqld
mkdir: cannot create directory ‘mysqld’: File exists
[root@k8s-master run]#
[root@k8s-master run]# cd mysqld
[root@k8s-master mysqld]#
[root@k8s-master mysqld]#
[root@k8s-master mysqld]# touch mysqld.pid sync
[root@k8s-master mysqld]#
[root@k8s-master mysqld]# chown -R root /var/run/mysqld
[root@k8s-master mysqld]#
[root@k8s-master mysqld]# chgrp -R root /var/run/mysqld
[root@k8s-master mysqld]#
[root@k8s-master mysqld]# chmod 777 /var/run/mysqld
[root@k8s-master mysqld]#
[root@k8s-master mysqld]#
[root@k8s-master mysqld]# systemctl start mysqld
[root@k8s-master mysqld]#
[root@k8s-master mysqld]#
[root@k8s-master mysqld]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
mysql>
mysql>