Showing posts with label mysql can not start after reboot. Show all posts
Showing posts with label mysql can not start after reboot. Show all posts

Nov 10, 2013

change data location of postgres and mysql on ubuntu 13.10

well, just a simple note how to change default data location of mysql and postgres on ubuntu saucy salamander (13.10)

 in this case, i show you to make /home/user/data_mysql and /home/user/data_postgres as default location of both.

changing data postgres 9.3 on ubuntu 13.10


febru@sevilla:~$ mkdir data_postgres
febru@sevilla:~$ sudo chown -R postgres:postgres data_postgres
febru@sevilla:~$ sudo pg_dropcluster --stop 9.3 main
febru@sevilla:~$ sudo pg_createcluster -d ~/data_postgres 9.3 main
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /home/febru/data_postgres
  locale en_US.UTF-8
  port   5432
febru@sevilla:~$ sudo /etc/init.d/postgresql start

change data location of mysql 5.5 on ubuntu 13.10


febru@sevilla:~$ mkdir data_mysql
febru@sevilla:~$ sudo chown -R mysql:mysql data_mysql
febru@sevilla:~$ sudo /etc/init.d/mysql stop
 * Stopping MySQL database server mysqld                                                                                                                                                                                   [ OK ]
febru@sevilla:~$ sudo cp -R -p /var/lib/mysql data_mysql
febru@sevilla:~$ sudo vim /etc/mysql/my.cnf

change location to
data_dir = /home/febru/data_mysql

febru@sevilla:~$ sudo vim /etc/apparmor.d/usr.sbin.mysqld 
change 
-  /var/lib/mysql/ r,
-  /var/lib/mysql/** rwk,
+  /home/febru/data_mysql/ r,
+  /home/febru/data_mysql/** rwk,

febru@sevilla:~$ sudo /etc/init.d/apparmor reload
 * Reloading AppArmor profiles                                                                                                                                                                                                    Skipping profile in /etc/apparmor.d/disable: usr.bin.firefox
Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
                                                                                                                                                                                                                           [ OK ]
febru@sevilla:~$ sudo /etc/init.d/mysql start
 * Starting MySQL database server mysqld      


if you get problem after restarting your computer, do this :

mysql can not start after reboot 

sudo tail -f /var/log/mysql/error.log

if you get :

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 

do this :
sudo  mysql_install_db -user=mysql -ldata=/home/febru/data_mysql               
Read more ...