I have downloaded and unpacked MySQL 5.6.12 to /opt/mysql/server-5.6
. I want to use this db instead of pre-installed 5.5 version. But neither version works.
When I want to start a server with mysqld --console
(pre-installed version) I get this error:
user@user-desktop:~$ sudo mysqld --console
[sudo] password for user:
130719 19:26:17 [Warning] Can't create test file /var/lib/mysql/user-desktop.lower-test
130719 19:26:17 [Warning] Can't create test file /var/lib/mysql/user-desktop.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2)
130719 19:26:17 [ERROR] Aborting
130719 19:26:17 [Note] mysqld: Shutdown complete
There are no any of these dirs in my system:
/var/lib/mysql/
/var/lib/mysql/
/var/lib/mysql/
How can it be? MySQL is pre-installed but dirs are absent. Should I create them manually? Or do I need to do smth else, run some program, to create them? What mode do I need to set for them?
There is some mysql_install_db
program in the system. Should I run it to set up MySQL?
Best Answer
Make sure that you installed MySQL as root
sudo apt-get install mysql-server
. This should usually work.To carry on from what you have here. You can create the missing directories but make sure they are owned by user\group mysql:
chown -R mysql:mysql /var/lib/mysql
If you would like to change MySQL's data directory, do so in MySQL's configuration file
/etc/mysql/my.cnf
Then you can chose between configuring apparmor to allow MySQL to read\execute\modify the new data directory and sub directories or, at your very own risk, you can remove apparmor. You may need to be
root
to do the following:Then you can run
mysql_install_db
.But then you will have no users in the database ! To solve this: