mysql_install_db on Ubuntu 16.04
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.
Related videos on Youtube
Dominik Wiśniewski
I'm a junior developer. For long time a programming with JavaScript and for some time I'm learning AngularJS. I love programming with VanillaJS and ES5 and AngularJS with others framework are very irritating for me. If I have something error then I can't even read it on debugger, because there are writing nothing about my errors. Grrrr When I ended project with Angular, I'm going to develop my ES script, maybe even ES6. In current time I obtained some projects from few companies which around me. For example do page for beauty salon
Updated on September 18, 2022Comments
-
Dominik Wiśniewski over 1 year
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 callmysqld --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?
-
minigeek over 7 yearsDid u try reinstalling mysql
-
minigeek over 7 yearsHow do you remove it ??.with autoremove or remove command??
-
Dominik Wiśniewski over 7 yearsThanks for your answer but I uninstalled almost the same to you through:
sudo apt-get purge mysql-server mysql-client mysql-common
thensudo apt-get autoremove
andsudo apt-get autoclean
and I have the same statement.. -
minigeek over 7 yearsI 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 runsudo 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 -
Dominik Wiśniewski over 7 yearsI did as you wrote, and I still can not go through step 2 this tutorial... digitalocean.com/community/tutorials/… because after
sudo mysql_install_db
a have still the same error which I wrote about earlier. -
minigeek over 7 yearsMay 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 runsudo mysql_install_db
-
Dominik Wiśniewski over 7 yearsIt 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 :|
-
minigeek over 7 yearsNever 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 :)
-
-
Dominik Wiśniewski over 7 yearsAfter I removed mysql and I installed again, I call
sudo mysql_install_db
and I get this error: