sudo vi /etc/apparmor.d/usr.sbin.mysqld
/path/to/new_mysql_data_dir/ r, /path/to/new_mysql_data_dir/** rwk,
sudo chown -R mysql:mysql /path/to/new_mysql_data_dir/
sudo /etc/init.d/apparmor restart sudo /etc/init.d/mysql restart
Search This Blog
Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts
Fix permissions after changing MySQL data directory
mysql: changing data directory requires change of apparmor settings
When changing mysql data directory from /var/lib/mysql to /Volumes/Store/mysql:
Your mysql will fail to start, and run
This is because apparmor are preventing mysqld from accessing unregistered directories.
To solve the problem, edit
then, start mysql server
sudo service mysql stop
sudo mv /var/lib/mysql /Volumes/Store/mysql
sudo service mysql start
Your mysql will fail to start, and run
dmesg, you can find the follow error:
[ 2012.069037] type=1400 audit(1357622820.131:47): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/Volumes/Store/mysql/nsp-precise.lower-test" pid=5300 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
This is because apparmor are preventing mysqld from accessing unregistered directories.
To solve the problem, edit
/etc/apparmor.d/usr.sbin.mysqld as root, and add following lines:
/Volumes/Store/mysql/ r,
/Volumes/Store/mysql/** rwk,
then, start mysql server
sudo service mysql start
See also
- http://informationideas.com/news/2010/04/15/changing-mysql-data-directory-require-change-to-apparmor/
Ubuntu: Migrate all mysql databases from one server to another
- On the new server, install mysql server:
sudo apt-get install mysql-server mysql-client - On the new server, stop the mysql server:
sudo service mysql stop - On the new server, backup /var/lib/mysql:
sudo mv /var/lib/mysql /var/lib/mysql.bak - On the old server, stop the mysql server:
sudo /etc/init.d/mysql stop - On the new server, mirror /var/lib/mysql directory from the old server:
sudo rsync -avz root@old_server:/var/lib/mysql /var/lib/ - On the new server, run
(NOTE: if you forget the root user password, you can reset the root password.)sudo mysql_upgrade -u root -p - Start mysql server on the new server:
sudo service mysql start
See also
Ubuntu: Install apache2, php5 and mysql
sudo apt-get install mysql-server mysql-client apache2 php5 libapache2-mod-php5 php5-mysql
mysql: reset root password
- Stop mysql service:
sudo service mysql stop - Start mysqld with following arguments: --skip-grant-tables and --skip-networking:
sudo mysqld --skip-grant-tables --skip-networking & - Run following command to upgrade the database:
sudo mysql_upgrade - Connect to mysql server:
mysql - Run following SQL clauses to change root password:
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; - Stop the msyql process:
sudo killall -9 mysqld - Start mysql service:
sudo service mysql stop
See also
MySQL: select records from multiple records
- Full join(Cross Join):
SELECT employee.id, employee.name, salary.amount FROM employee, salary WHERE employee.id=salary.employee_id;
- Left/Right join:
SELECT employee.id, employee.name, salary.amount LEFT JOIN ON employee.id=salary.employee_id;
SEE ALSO
MySQL: export data to csv file
SELECT employee.id, employee.name, employee.salary INTO OUTFILE '/tmp/employee.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM employee;
Subscribe to:
Posts (Atom)