0 like
2575 reads

重装mysql后mysql.server start 启动报错

重装mysql后mysql.server start 启动报错 mysql.server startERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid).

重装mysql后mysql.server start 启动报错

mysql.server startERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid).

 

网上尝试了各种办法都没能解决,于是就自己查了一下原因查看报错信息 vim /usr/local/var/mysql/MacBook-Pro.local.pid

找到报错信息

2020-11-03T03:35:36.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/MacBook-Pro.local.pid ended
2020-11-03T03:35:44.6NZ mysqld_safe Logging to '/usr/local/var/mysql/MacBook-Pro.local.err'.
2020-11-03T03:35:44.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
2020-11-03T03:35:44.645249Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-11-03T03:35:44.645559Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2020-11-03T03:35:44.645601Z 0 [Note] /usr/local/opt/mysql@5.7/bin/mysqld (mysqld 5.7.32) starting as process 22408 ...
2020-11-03T03:35:44.649052Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2020-11-03T03:35:44.650698Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-11-03T03:35:44.650727Z 0 [Note] InnoDB: Uses event mutexes
2020-11-03T03:35:44.650739Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-11-03T03:35:44.650748Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-11-03T03:35:44.651048Z 0 [Note] InnoDB: Number of pools: 1
2020-11-03T03:35:44.651166Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-11-03T03:35:44.652617Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-11-03T03:35:44.662581Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-11-03T03:35:44.702036Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-11-03T03:35:44.712377Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-11-03T03:35:44.712517Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-11-03T03:35:44.722212Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-11-03T03:35:44.722942Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-11-03T03:35:44.722976Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-11-03T03:35:44.723175Z 0 [Note] InnoDB: Waiting for purge to start
2020-11-03T03:35:44.837230Z 0 [Note] InnoDB: 5.7.32 started; log sequence number 1210208
2020-11-03T03:35:44.837729Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2020-11-03T03:35:44.837852Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-11-03T03:35:44.837979Z 0 [Note] InnoDB: Buffer pool(s) load completed at 201103 11:35:44mysqld: Table 'mysql.plugin' doesn't exist' 
2020-11-03T03:35:44.838270Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2020-11-03T03:35:44.838479Z 0 [ERROR] unknown variable 'mysqlx-bind-address=127.0.0.1'
2020-11-03T03:35:44.838495Z 0 [ERROR] Aborting

不知什么原因,导致mysql.plugin这个表没能创建

于是尝试重新初始化数据库执行命令mysqld --initialize

依然是报错信息

2020-11-03T13:41:18.389783Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-11-03T13:41:18.391764Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2020-11-03T13:41:18.391793Z 0 [ERROR] Aborting

 

是因为安装的时候初始化过了,所以指定的位置有文件了,因为是新安装的数据库,删除数据毫无压力。找到mysql数据库储存的位置,还记得之前的报错信息吗。ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid).这行。

 

mysql的数据就在/usr/local/var/mysql/ 里那么,找到地方就简单很多了

执行命令cd /usr/local/var/rm -rf mysql重新初始化数据库mysqld --initialize   

 

输出信息

2020-11-03T13:47:49.030326Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-11-03T13:47:49.032605Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2020-11-03T13:47:49.142842Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-11-03T13:47:49.166303Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-11-03T13:47:49.220100Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2942856a-1ddb-11eb-aa1e-f4787e0fcedb.
2020-11-03T13:47:49.232327Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-11-03T13:47:49.436401Z 0 [Warning] CA certificate ca.pem is self signed.
2020-11-03T13:47:49.510757Z 1 [Note] A temporary password is generated for root@localhost: lwZ%3i&7!Lrs

 

功夫不负整天敲代码的人,它成了

接下来就是常规操作了

启动数据库

mysql.server start

 

登陆数据库

mysql -uroot -p

 

至于密码,看上面输出的信息

2020-11-03T13:47:49.510757Z 1 [Note] A temporary password is generated for root@localhost: lwZ%3i&7!Lrs

 

所以我的初始密码是 lwZ%3i&7!Lrs

心情是那个激动啊,看一下数据库

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

 

看到已经对ERROR有心理阴影了

腚眼一看,噢, 原来是忘了修改初始密码了

贴出代码:

alter user 'root'@'localhost' identified by 'new_password';

 

好啦,已经完成mysql的重装

 

我的解决方案,记录一下