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:


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?


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:

/etc/init.d/apparmor stop
/etc/init.d/apparmor teardown
update-rc.d -f apparmor remove
apt-get purge apparmor

Then you can run mysql_install_db.

But then you will have no users in the database ! To solve this:

mysqld --skip-grant-tables --skip-networking & #Start MySQL manually with no authentication checks
mysql # Access MySQL, no username\password needed
use mysql;
INSERT INTO `user` (`Host`, `User`, `Password`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`) VALUES('localhost','root',PASSWORD('root'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','','0','0','0','0'); #Add root user with passowrd, root
GRANT ALL ON *.* TO 'root'@'localhost';
killall mysqld;
start mysql
mysql -u root -p
# Enter password, which is: root

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.