"Can't create test file /var/lib/mysql/user-desktop.lower-test": How to run mysql server on Xubuntu 13.04 (kubuntu-desktop)
Solution 1:
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
reboot
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;
DELETE FROM user;
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
FLUSH PRIVILEGES;
GRANT ALL ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
exit;
killall mysqld;
start mysql
mysql -u root -p
# Enter password, which is: root