An error occurred while configuring multiple instances in mysqld_multi and mysql_install_db.

Source: Internet
Author: User

Ubuntu8.04 ~ 8.10 install the default MySQL instance. You cannot run mysql_install_db. You cannot use mysqld_multi to configure apparmor and apparmor ), an error occurs because apparmor controls the permission to access the data directory of the multi instance.
Error code:

> Sudo mysql_install_db -- datadir =/var/lib/mysql1 -- no-defaults -- user = MySQL
Installing MySQL system tables...
100304 22:34:18 [Warning] can't create test file/var/lib/mysql1/PB. Lower-test
100304 22:34:18 [Warning] can't create test file/var/lib/mysql1/PB. Lower-test
Error: 1005 can't create table 'db' (errno: 13)
100304 22:34:18 [Error] aborting

Solution:
Edit/etc/apparmor. d/usr. sbin. in the mysqld file, you can see that the data directory, logs, and Socket of MySQL installed with APT-Get by default exist. the permissions of the PID file are as follows:

/Etc/MySQL/*. pem R,
/Etc/MySQL/CONF. d/R,
/Etc/MySQL/CONF. d/* r,
/Etc/MySQL/My. cnf r,
/Usr/sbin/mysqld Mr,
/Usr/share/MySQL/** R,
/Var/log/MySQL. Log RW,
/Var/log/MySQL. Err RW,
/Var/lib/MySQL/R,
/Var/lib/MySQL/** rwk,
/Var/log/MySQL/R,
/Var/log/MySQL/* RW,
/Var/run/mysqld. pid w,
/Var/run/mysqld. Sock W,

/Var/log/mysql1.log RW,
/Var/log/mysql1.err RW,
/Var/lib/mysql1/R,
/Var/lib/mysql1/** rwk,
/Var/log/mysql1/R,
/Var/log/mysql1/* RW,
/Var/run/mysqld/mysqld1.pid W,
/Var/run/mysqld/mysqld1.sock W,

/Var/log/mysql2.log RW,
/Var/log/mysql2.err RW,
/Var/lib/mysql2/R,
/Var/lib/mysql2/** rwk,
/Var/log/mysql2/R,
/Var/log/mysql2/* RW,
/Var/run/mysqld/mysqld2.pid W,
/Var/run/mysqld/mysqld2.sock W,

After this file is modified, sudo/etc/init. d/apparmor restart and restart apparmor.

Continue to run sudo mysql_install_db-datadir =/var/lib/mysql1-no-defaults-user = MySQL
In this way, the MySQL System data file can be installed under/var/lib/mysql1.

It is easy to configure multiple instances: edit/etc/MySQL/My. CNF

[Mysqld_multi]
Mysqld =/usr/bin/mysqld_safe
Mysqladmin =/usr/bin/mysqladmin
User = root
Password = 123

[Mysqld1]
PID-file =/var/run/mysqld/mysqld1.pid
Socket =/var/run/mysqld/mysqld1.sock
Port = 3306
Datadir =/var/lib/mysql1
User = MySQL
Log =/var/log/mysql1.log

[Mysqld2]
PID-file =/var/run/mysqld/mysqld2.pid
Socket =/var/run/mysqld/mysqld2.sock
Port = 3307
Datadir =/var/lib/mysql2
User = MySQL
Log =/var/log/mysql2.log

Run sudo mysqld_multi start 1, 2-no-log to view the terminal's output of the correct startup information.

~ /Home/Pb $ netstat-lt | grep 33
TCP 0 0 *: 3307 *: * listen
TCP 0 0 *: 3308 *: * Listen http://www.neocanable.com/error-for-mysql-multi-and-mysql-install-db/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.