3

I have a problem with install mysql_install_db.

When I call mysql_install_db I get this error:

[WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-10-10 16:06:57 [ERROR]   The data directory needs to be specified.
root@furniture-ecommerce:~# mysqld --initialize
2016-10-10T16:13:24.343724Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-10-10T16:13:24.350429Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2016-10-10T16:13:24.350786Z 0 [ERROR] Aborting

I deleted the directory /var/lib/mysql as here recommend - post but when I call mysqld --initialize then this error occurs:

mysqld: Can't create directory '/var/lib/mysql/' (Errcode: 13 -     Permission denied)
2016-10-10T16:23:29.515470Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-10-10T16:23:29.519420Z 0 [ERROR] Aborting

Can you help me with it?

3 Answers3

3

I recommend you do the following.
Create the directory:

mkdir -p /var/lib/mysql

Note: If you want to change the default dir above for mysql data storage, then you need to add the new dir in the apparmor config as well in order to use.

Install MySQL server packages and others.

sudo apt-get install mysql-server mysql-client mysql-common

Apply ownership and permissions required.

chown -R mysql.mysql /var/lib/mysql
chmod -R 775 /var/lib/mysql

If you don't want apparmor to make unnecessary issues, better disable it as follows.

sudo service apparmor stop
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo service apparmor restart
sudo aa-status

Now reboot the system.

sudo reboot

Now initialise MySQL as follows.

mysql_install_db

Check everything went fine. You can now use secure installation procedure.

sudo mysql_secure_installation

Thats all.

Zanna
  • 72,312
SAGAR Nair
  • 1,415
0

Open terminal and type :

sudo apt-get purge mysql-server

(Can also put mysql*)

sudo apt-get autoclean
sudo apt-get install mysql-server
Zanna
  • 72,312
minigeek
  • 1,071
0

I have deleted/moved the content of /var/lib/mysql/, but not the directory itself. I tried again to run

sudo mysqld --initialize

and it worked, and created new content within the /var/lib/mysql/ directory

Zanna
  • 72,312