CentOS7 でソースコードを使用して MySQL8.0.31 をインストールしたら、起動に失敗するという問題が発生しました。!!
問題文:
mysql のインストールが完了したら、通常は次のコマンドを使用して mysql を起動できます。
bin/mysqld_safe --user=mysql &
通常の状況では、起動コマンドを入力した後、次のコマンドと初期パスワードを入力して mysql に入ります。
bin/mysql -uroot -p #执行该命令后出入初始密码,进入mysql
しかし今日、mysql 起動コマンドを実行すると、次のプロンプトが表示されます。
2023-07-31T08:17:42.131276Z mysqld_safe mysqld from pid file /usr/local/mysql/data/mysqld.pid ended
説明: 上記の意味は、おそらく mysql サービスが停止したことを意味しているため、bin/mysql -uroot -pと初期パスワードを後で入力しても、mysql を入力することはできず、次のエラーが表示されます。
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/data/mysql.sock'
それ以来!!!
MySQL インストール ディレクトリ (私のディレクトリは /usr/local/mysql/data/) のmysqld.logを確認しました 。ログの内容は次のとおりです。
2023-07-31T08:06:55.802016Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:06:55.802126Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) initializing of serv in progress as process 20348
2023-07-31T08:06:55.810198Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:06:56.695475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:06:58.639754Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >alonj%-Z4j*
[root@vm10-0-0-236 data]# cat mysqld.log
2023-07-31T08:06:55.802016Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:06:55.802126Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) initializing of serv in progress as process 20348
2023-07-31T08:06:55.810198Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:06:56.695475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:06:58.639754Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >alonj%-Z4j*
2023-07-31T08:07:23.268585Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:07:23.268698Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) starting as process 584
2023-07-31T08:07:23.276568Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:07:23.343831Z 1 [ERROR] [MY-012562] [InnoDB] We scanned the log up to 19325952. A checkpoint was at 19325996 a the maximum LSN on a database page was 0. It is possible that the database is now corrupt!
2023-07-31T08:07:23.343866Z 1 [Warning] [MY-013412] [InnoDB] The last block of redo had corrupted first_rec_group and becameixed (0 -> 44).
2023-07-31T08:07:23.536217Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:07:24.624559Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X otocol won't be accessible'
2023-07-31T08:07:24.624590Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 fled, `bind()` failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx
2023-07-31T08:07:24.624597Z 0 [ERROR] [MY-013597] [Server] Plugin mysqlx reported: 'Value '*' set to `Mysqlx_bind_address`, Plugin can't bind to it. Skipping this value.'
2023-07-31T08:07:24.624606Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' fail, another process with PID 20155 is using UNIX socket file'
2023-07-31T08:07:24.771731Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-07-31T08:07:24.771770Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connectis are now supported for this channel.
2023-07-31T08:07:24.771954Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use
2023-07-31T08:07:24.771961Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3307 ?
2023-07-31T08:07:24.771972Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-07-31T08:07:25.802572Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.31) urce distribution.
2023-07-31T08:07:47.681777Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-07-31T08:07:47.681887Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) starting as process 816
2023-07-31T08:07:47.688141Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-31T08:07:47.847692Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-31T08:07:48.938404Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X otocol won't be accessible'
2023-07-31T08:07:48.938441Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 fled, `bind()` failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx
2023-07-31T08:07:48.938453Z 0 [ERROR] [MY-013597] [Server] Plugin mysqlx reported: 'Value '*' set to `Mysqlx_bind_address`, Plugin can't bind to it. Skipping this value.'
2023-07-31T08:07:48.938471Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' fail, another process with PID 20155 is using UNIX socket file'
2023-07-31T08:07:49.039721Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-07-31T08:07:49.039752Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connectis are now supported for this channel.
2023-07-31T08:07:49.039916Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use
2023-07-31T08:07:49.039923Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3307 ?
2023-07-31T08:07:49.039935Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-07-31T08:07:50.108334Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.31) urce distribution.
そのうちの 1 行には次のように書かれています。
2023-07-31T08:07:49.039923Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3307 ?
説明: この行は、おそらく現在のポートがすでに占有されていることを意味します (設定でポート番号を 3307 として指定しました。指定しない場合、デフォルトは 3306 です)。
解決:
ポート番号に対応するプロセス ID を見つけてプロセスを強制終了し、ポート番号を解放します。
次のコマンドを実行して (3307 は mysql のポート番号です)、ポート番号に対応するプロセス ID を確認します。
lsof -i:3307
実行結果は以下のようになります。
次のコマンドを実行してプロセスを強制終了します。
kill -9 20155
占有されているポート番号を解放すれば、上記の問題は解決されます。!!
問題が解決すると、MySQL の起動結果は次のようになります。