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?

  • Did u try reinstalling mysql – minigeek Oct 11 '16 at 09:02
  • Yes and each time I have the same statement – Dominik Wiśniewski Oct 11 '16 at 11:53
  • How do you remove it ??.with autoremove or remove command?? – minigeek Oct 11 '16 at 13:19
  • Thanks for your answer but I uninstalled almost the same to you through: `sudo apt-get purge mysql-server mysql-client mysql-common` then `sudo apt-get autoremove` and `sudo apt-get autoclean` and I have the same statement.. – Dominik Wiśniewski Oct 11 '16 at 17:10
  • I still think mysql is not installed properly...and why do u remove those directories!!?..i have mysql installed and mysql _install_db is working fine..... May b u should try `sudo apt-get purge mysql*` and then run `sudo apt-get install --reinstall mysql-server` this time dont install anything else..and just setup mysql and login using mysql -u root -p if it let u loggin..it is installed properly...and now run what you wanted to run at beginning – minigeek Oct 11 '16 at 18:08
  • I did as you wrote, and I still can not go through step 2 this tutorial... https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 because after `sudo mysql_install_db` a have still the same error which I wrote about earlier. – Dominik Wiśniewski Oct 12 '16 at 16:27
  • May be before doing that you should run `sudo mysql_secure_installation` This will prompt you for the root password you created in step one(installing sql and giving password). You can press ENTER to accept the defaults for all the subsequent questions, with the exception of the one that asks if you'd like to change the root password. You just set it in step one, so you don't have to change it now...now run `sudo mysql_install_db` – minigeek Oct 12 '16 at 16:32
  • It did not help, but I find solution! I found the topic of the solution, but the title was not clear, but it's ok. I am very grateful for your taking the time! Unfortunately I can not give up on your voice, because I'm new :| – Dominik Wiśniewski Oct 12 '16 at 18:03
  • Never mind...this forum is to find solution.. glad you got one:) gud luck...and write the solution here..so other people can find it easily :) – minigeek Oct 13 '16 at 04:38

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
  • 69,223
  • 56
  • 216
  • 327
SAGAR Nair
  • 1,335
  • 9
  • 13
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
  • 69,223
  • 56
  • 216
  • 327
minigeek
  • 1,071
  • 7
  • 13
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
  • 69,223
  • 56
  • 216
  • 327