The user that runs the MySQL daemon doesn’t have permission to write to your database directory.
If you’re using a standard installation with default settings, the following command should fix that (edited to add sudo based on your edited output: if you can run as root, leave off the sudo):
sudo chown -R mysql:mysql /var/lib/mysql
You can find exactly what user it is (if it’s not mysql) by looking for the user= option in /etc/my.cnf, or /etc/mysql/my.cnf.
11
solved MySQL Error Files [closed]