# Mysqld 5.7.36-log  mysql server wont start



## redmend67 (Dec 22, 2021)

Hi,  My mysql server stopped working. I updated to the latest mysql 5.1.36 version. 
I need help on fixing the issues. 

Here's the error logs:
MYSQL eeror log:

```
mysqld_safe Starting mysqld daemon with databases from /var/db/mysql.backup
ld-elf.so.1: Shared object "liblz4.so.1" not found, required by "mysqld"
mysqld_safe mysqld from pid file /var/db/mysql.backup/host.com.pid ended

/usr/local/libeec/mysqld (mysqld 5.7.36-log) starting process as 13470 ...
[ERROR] Can't find error-message file '/usr/local/etc/mysql/share/mysqlerrmsg.sys'. heck error-message file location and 'lc-messages-dir' confirguation directive.

0 [Note] InnoDB: Mutexes and rq_locks use GCC atomic builtins
0 [Note] InnoDB: Uses event mutexes
0 [Note] InnoDB: GCC builtin __atomic_thread_fense() is used for memory barrier
0 [Note] InnoDB: Compressed tables use zlib 1.2.11
0 [Note] InnoDB: Number of pools: 1 
0 [Note] InnoDB: Note using CPU crc32 instructions
0 [Note] InnoDB: Initializing buffer pool, total size= 128m, instances=1, chunk ize=128m
0 [Note] InnoDB: Completed initialization of buffer pool
0 [Note} InnoDB: Highest upported file format is Barracuda.
0 [Note] InnoDB: Creating shared tablespace for temporary tables
0 [Note] InnoDB: Setting file './ibtmp1' size to 12mb. Physically writing the file full; Pleae wait ...
0 [Note] InnoDB: File './ibtmp1' size is now 12mb
0 [Note] InnoDB: 96 redo rollback segment(s) found
96 redo rollback segment(s) are active.
0 [Note] InnoDB: 32 non-redo rollback segment(s) are active
0 [Note] InnoDB: Waiting for purge to start
0 [Note] InnoDB: 5.7.36 started; log sequence number 1210135
0 [Note] InnoDB: Loading buffer pool(s) from /var/db/mysql.backup/ib_buffer_pool
0 [Note] InnoDB: Butter Pool(s) loaded completed at 211222
0 [Note] InnoDB: Plugin 'FEDERATED' is disabled
0 [Note] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. 
Please refer to [URL]http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html[/URL] for how to resolve the issue.
mysqld: Unknown error 1146
0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 
0 [ERROR] Too many arguments ( first extra is 'start').
0 [Note] Use --verbose --help to get a list of available options!
0 [ERROR] Aborting
0 [Note] Binlog end
0 [Note] shutting down plugin 'ngram'
0 [Note] shutting down plugin 'partition'
0 [Note] shutting down plugin 'BLACKHOLE'
0 [Note] shutting down plugin 'ARCHIVE'
0 [Note] shutting down plugin 'PERFORMANCE_SCHEMA'
0 [Note] shutting down plugin 'MRG_MYISAM'
0 [Note] shutting down plugin 'MyISAM'
0 [Note] shutting down plugin 'INNODB_SYS_VIRTUAL'
0 [Note] shutting down plugin 'INNODB_SYS_DATAFILES'
0 [Note] shutting down plugin 'INNODB_SYS_TABLESPACE'
0 [Note] shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
0 [Note] shutting down plugin 'INNODB_SYS_FOREIGN'
0 [Note] shutting down plugin 'INNODB_SYS_FIELDS'
0 [Note] shutting down plugin 'INNODB_SYS_COLUMNS'
0 [Note] shutting down plugin 'INNODB_SYS_INDEXES'
0 [Note] shutting down plugin 'INNODB_SYS_TABLESTATS'
0 [Note] shutting down plugin 'INNODB_SYS_TABLES'
0 [Note] shutting down plugin 'INNODB_FT_INDEX_TABLE'
0 [Note] shutting down plugin 'INNODB_FT_INDEX_CACHE'
0 [Note] shutting down plugin 'INNODB_FT_CONFIG'
0 [Note] shutting down plugin 'INNODB_FT_BEING_DELETED'
0 [Note] shutting down plugin 'INNODB_FT_DELETED'
0 [Note] shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
0 [Note] shutting down plugin 'INNODB_METRICS'
0 [Note] shutting down plugin 'INNODB_TEMP_TABLE_INFO'
0 [Note] shutting down plugin 'INNODB_BUFFER_POOL_STARTS'
0 [Note] shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
0 [Note] shutting down plugin 'INNODB_BUFFER_PAGE'
0 [Note] shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
0 [Note] shutting down plugin 'INNODB_CMPMEM_RESET'
0 [Note] shutting down plugin 'INNODB_CMPMEM'
0 [Note] shutting down plugin 'INNODB_CMP_RESET'
0 [Note] shutting down plugin 'INNODB_CMP'
0 [Note] shutting down plugin 'INNODB_LOCK_WAITS'
0 [Note] shutting down plugin 'INNODB_LOCKS'
0 [Note] shutting down plugin 'INNODB_TRX'
0 [Note] shutting down plugin 'InnoDB'
0 [Note] InnoDB: FTS optimized thread exiting.
0 [Note] InnoDB: starting shutdown . . .
0 [Note] InnoDB: Dumping buffer pool(s) to /var/db/mysql.backup/ib_buffer_pool
0 [Note] InnoDB: Buffer pool(s) dump completed at 211222 
0 [Note] InnoDB: Shutdown completed; log sequence number 1210154
0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
0 [Note] shutting down plugin 'MEMORY'
0 [Note] shutting down plugin 'CSV' 
0 [Note] shutting down plugin 'sha256_password'
0 [Note] shutting down plugin 'mysql_native_password'
0 [Note] shutting down plugin 'binlog'
0 [Note]
```

If you look at the log it looks like I have to run mysql_upgrade.

I updated mysql from mysql 5.6 to mysql 5.7. I read online that mysql_upgrade is used for older versions and with the newer versions it's not needed. The upgrade or update does it automatically. 

I need to know what should I be doing?  The mysql.backup is the name of the folder. I have a folder for mysql and mysql.backup and mysql.backup2 I just have made copies of the folder just in case I screw something. So mysql is config to look at mysql.backup folder as a live location to lookup databases  info. 

I have no clue what to do or how to do it and need guidance. I am guessing I have to run the mysql_upgrade to reconstruct the database files? Let me know what I need to do to get my server back up and running. 

Thanks


----------



## SirDice (Dec 23, 2021)

redmend67 said:


> The upgrade or update does it automatically.


It doesn't.


----------



## mark_j (Dec 23, 2021)

redmend67 said:


> < ... >
> . I read online that mysql_upgrade is used for older versions and with the newer versions it's not needed. The upgrade or update does it automatically.


Oh no, tell me you don't believe everything you read on the internet? 

I would suggest that you follow what mysql is telling you, regardless of the wisdom you gained from the interwebs. 


> Please run mysql_upgrade to create it.



You've copied the mysql data files, so, should the excrement hit the oscillation you can always set your datadir to that directory and back-out of 5.7.


----------



## VladiBG (Dec 23, 2021)

> ld-elf.so.1: Shared object "liblz4.so.1" not found, required by "mysqld"


you need archivers/liblz4


----------



## redmend67 (Dec 23, 2021)

VladiBG said:


> you need archivers/liblz4


I have it installed. I even did `pkg install liblz4`  and it said it's already installed. So, I went to ports and did a command `make reinstall clean`  command and it reinstalled liblz4. I don't know if it will clear that error.  Got any other tips?


----------



## redmend67 (Dec 23, 2021)

SirDice said:


> It doesn't.


How would one go about doing it then is there any tutorial online to show me how todo this in a safe manner. I don't want to lose data or screw things up.  I would like to view material about what is expected out of me to do this. Thanks Guys!


----------



## redmend67 (Dec 23, 2021)

mark_j said:


> Oh no, tell me you don't believe everything you read on the internet?
> 
> I would suggest that you follow what mysql is telling you, regardless of the wisdom you gained from the interwebs.
> 
> ...


How does one run it? I am new to this. I only experienced dowloading and installing mysql. I never had the experience to upgrade mysql to a newer version and never went thru this process.  I would like to know what I need to do to run it properly without breaking anything. Thanks Guys! 


I ran mysql_upgrade and it spit out 
	
	



```
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38) while connecting to the MySQL server Upgrade process encountered error and will not continue.
```
What does this mean and how would one fix it?  I checked there's a mysql.sock file in folder tmp and the tmp and file mysql.sock has chown mysql and chmod 777 permissions. Any ideas?


----------



## VladiBG (Dec 24, 2021)

You can't mix ports and pkgs. 
How did you upgrade the MySQL?



> I read online that mysql_upgrade is used for older versions and with the newer versions it's not needed


It's true for version >MySQL 8.0.16


----------



## redmend67 (Dec 24, 2021)

VladiBG said:


> You can't mix ports and pkgs.
> How did you upgrade the MySQL?
> 
> 
> It's true for version >MySQL 8.0.16


I tried to do it thru ports but it just fails. So, I upgraded via pkg and it's because with ports it doesn't grab or upgrade depend libraries used so it would have missing files. I  would then delete the mysql server and client and then use pkg which would grab all dependencies  and upgrade not just mysql but all the depend libs.

I have the liblz4 installed. 

I ran 
	
	



```
find / -name liblz4.so.1
```
  It gave me locations:


```
/usr/local/lib/liblz4.so.1
/usr/usr/local/lib/liblz4.so.1
/root/usr/local/lib/liblz4.so.1
```

That's where the file is located and I still get the error in the mysql logs. It looks like this is preventing me from running mysql in safe mode. Right after the error message the pid gets deleted . 

What can I do to get mysql to see where the file is located. I have to use the path:
	
	



```
/usr/local/lib/liblz4.so.1
```


----------



## VladiBG (Dec 24, 2021)

Again, you can't mix ports and pkg as you will end up with conflicting versions of dependencies.
You need to delete both MySQL client/server. Then use `pkg autoremove` to clean up all left dependencies and after that to install again MySQL Client/server. If you have any other software installed via ports then you have to use ports to build and install MySQL. If you don't have anything else installed via ports and you are using only pkg then use pkg to install MySQL.

Note:
after `pkg autoremove` you may need to reinstall some programs, so take a note first which pkg will be removed.


----------



## redmend67 (Dec 26, 2021)

VladiBG said:


> Again, you can't mix ports and pkg as you will end up with conflicting versions of dependencies.
> You need to delete both MySQL client/server. Then use `pkg autoremove` to clean up all left dependencies and after that to install again MySQL Client/server. If you have any other software installed via ports then you have to use ports to build and install MySQL. If you don't have anything else installed via ports and you are using only pkg then use pkg to install MySQL.
> 
> Note:
> after `pkg autoremove` you may need to reinstall some programs, so take a note first which pkg will be removed.


I did this and it removed 125 programs. I had to reinstall dovecot but this time from ports. The problem is cmake got remove. I couldn't do a build clean install from ports. I had to use  portmaster which used ports to install cmake but before the I had to install a py lib which was needed in the latest version.  I used portmaster to install mysql57-client and server 30 etc and still get the same error message. I still get the same error message with liblz4. the autoremove removed it and It got installed with portmaster when I tried to install mysql.  So, it's installed via ports . Yet, I  still get an error message. I don't know if I haveto restart the server for it to take effect or not but didn't restart the computer.


----------



## VladiBG (Dec 26, 2021)

Force rebuild all ports using portmaster or `portupgrade -af`

Is this a typo:


> /usr/local/*libeec*/mysqld (mysqld 5.7.36-log) starting process as 13470 ..


----------



## redmend67 (Dec 26, 2021)

VladiBG said:


> Force rebuild all ports using portmaster or `portupgrade -af`
> 
> Is this a typo: /usr/local/*libeec*/mysqld (mysqld 5.7.36-log) starting process as 13470 ..


I will give that a try. Before I read your post. I  did this  
	
	



```
LDD /usr/local/libexec/mysqld
```
 This gave me a list of libs it will looking for. One of the list has liblz4.so.1  it was located 
	
	



```
/usr/local/lib/lizlz4.so.1
```
  I did a 
	
	



```
chmod 777
```
 to that file and after that ran mysqld and it didn't show the error of the missing liblz4.so.1 .  So it cleared that error message.

Yes, the 
	
	



```
/usr/local/libeec/mysqld (mysqld 5.7.36-log) starting process as 13470 ..
```

is a type I meant to type in 
	
	



```
/usr/local/libexec/mysqld (mysqld 5.7.36-log) starting process as 13470 ..
```

this is how I am to run the mysql server by typing 
	
	



```
/usr/local/libexec/mysqld
```
 into terminal but read below on the update part because I  got the server to start up but there's still issues. I don't know what default password it made for root and don't know if it wipe out my previous users and passwords used to login to mysql.

However, I still got the rest error messages like error 
	
	



```
[ERROR] Can't find error-message file '/usr/local/etc/mysql/share/mysql/errmsg.sys'. Check error-message file location and 'lc-message-dir' configuration directive.
```
  This is followed by the same original error message with the notes of InnoDB.

I looked at the logs  and noticed  it doesa a InnoDB Buffer pool(s) load completed. After this is where it breaks it gives a mysqld: Unknown error 1146.

Then it says [ERROR] can't open the mysql.plugin table. Please run mysql_upgrade to create it. I am guessing I need to try and run this again.  I tried this before but got an error on the socket cannot be found.


UPDATE:  I  was able to get mysql server to run.  I  found out it's looking for errmsg.sys  in the location /usr/local/etc/mysql/shared/mysql  which doesn't exist. I google searched around and found out the file is located in /usr/local/share/mysql   but I don't know how to permently to correct this. I know I can change the location when running mysqld  in command line using arguments.  Which I did which cleared the errmesg.sys error in the logs.

Then I just renamed   made a folder named mysqldata in  /var/db/mysql/  so it be /var/db/mysql/mysqldata.
I changed the data_dir to the new empty file andthen ran mysqld using the --initialization. It created new folder.

I then ran mysqld by command line  but  when running mysqld in command line I cannot type anything in the command it runs the server but I have to use ctrl + \  to get out but it stops the server cold turkey.

I then ran it using mysqld_safe  and now it works and runs. I  noticed it change or made  new mysql user password for root.

So, I can get it to run using mysqld_safe but the question  is there a way I an run mysql upgrade? to fix the databases in the other folders? the other folders holds my original setup and databases which my understanding that I needed the server to be running to run mysql upgrade but I need to know if I can use this directly what folder to fix the databases and tables?


----------



## VladiBG (Dec 27, 2021)

Edit /usr/local/etc/mysql/my.cnf and use provided rc.d script to start MySQL via /usr/local/etc/rc.d/mysql-server


----------



## redmend67 (Dec 27, 2021)

VladiBG said:


> Edit /usr/local/etc/mysql/my.cnf and use provided rc.d script to start MySQL via /usr/local/etc/rc.d/mysql-server



I have that setup where I can use service mysql-server start or stop or status etc nd it works. 

The issue is that by default the mysql looks for the errmsg.sys in /usr/local/etc/mysql/share/mysql    which didn't exist but I made the directories /share/mysql in there and added a copy of the errmsg.sys file but that for some reason doesn't work.

So, if I run the way you ask me by default it will still give me errors saying it cannot find errmsg.sys etc . Even though I made the directory and copied the file over and I think it's just permission issues that's causing this.

However, if I ran the code you suggested and add arguments I can change the directory .. by default the file is actually located in /usr/local/share/mysql    so, I pass on the arguments  to change the directory back to /usr/local/share/mysq but I have to do this in terminal every time.  I then loads up the errmsg.sys file with no issues that way. 

the arguments I used for mysqld is 
	
	



```
/usr/local/libexec/mysqld --lc_messages_dir=/usr/local/share/mysql  -- datadir=/var/dbmysql/mysqldata
```

I had to run mysqld --initialized to the empty folder I made called mysqldata which built the files needed and database needed.
This allowed me to use the folder to start the mysql server with no major issues. While doing so I think it generateded a root user with a random generated password which showed this to me. I wrote it on another computer but I tried the username root and the password provided to login to mysql server but it keeps failing.  So, I don't know if it's using a new user system or still using the previous one in place. 

Right now I can see mysqld running in socketstat.  So, I know now it's runnning. The problem is I thin the other directories has my databases tables and it seems it needs to be reconstructed might be currupted. I want to know if it's possible to use mysql-upgrade to just fix those database issues and then use the other folders as the data directory and will it bring back the previous system back online? 

Thanks


----------



## richardtoohey2 (Dec 27, 2021)

I've upgraded a number of FreeBSD machines from MySQL 5.6 to 5.7 and it's never been this much trouble (there have been database issues with the actual changes from 5.6 to 5.7 but not the upgrading and starting of MySQL itself.)

You seem to be doing things in a non-standard way and this appears to be causing you a lot of issues.  I've not had to copy files or change command-line parameters or change permissions - it should just all work.

Have you got a spare machine or VM that you can run through the process with?

Start with a fresh install of FreeBSD.

Install MySQL 5.*6*, import your databases from backup, check it looks OK (i.e. is close to your real set-up.)

Run the upgrade process to MySQL 5.*7*, including the mysql_upgrade, check the databases look OK.

If anything goes wrong, try again - find a process that works and document it.

Then try that process on your main machine, maybe including re-installing MySQL 5.6 and starting from that.

From my notes - and this is using ports, and just doing things the way I do them, NOT saying "best" or recommended - but did work for me.

So MySQL 5.6 installed.

mysqldump (just in case)
stop mysqld
pkg delete mysql56-server mysql56-client
make install mysql57-server
sort out my.cnf
start mysql 5.7
mysql-upgrade
restart mysql 5.7

Done - we're on 5.7.

On fresh installs of 5.7 I've had to watch out for the root password generation step, but don't think that was an issue with the upgrade.


----------

