How to compile and install a second MySQL database under Ubuntu

Source: Internet
Author: User

My system already has a MySQL, and then compile a MySQL, the most troublesome place is not compile, but let two coexistence.

There is no difference between the previous compile link and the normal installation, or the Configure,make,make install. When configure, select the location of the installation, or it may cause the original file to be overwritten (using the –prefix option). My broken computer made when it took a lot of time (specific how much I also do not know, start compiling after the meal), after installation, according to the MySQL manual copy support-files/ MY-MEDIUM.CNF to the installation directory in the Var directory (the folder does not exist when the database is not installed, you create a root directory under the installation), and then modify the inside of the client communication using the name of the socket file Sed-i-e ' s/mysql.sock/ mysql1.sock/'/opt/mysql/var/ MY.CNF, here the socket file changed to Mysql1.sock (the original MySQL default socket file is Mysql.sock, do not modify will cause two socket file conflict). If you want to listen through the network at the same time, may also need to modify the inside of the listening port, anyway, I just as a job demo, so the listening port is not modified.

The following operation is the same as in the manual, lazy, do not export environment variables, so to enter an absolute path. First change the owner of the folder, and then use Mysql_install_db–user=mysql to create the database (here to prevent the use of the original path of the MySQL program). Finally start Mysql,mysqld_safe–user=mysql & (Still the same, be careful not to use the original MySQL program).

At this time, the new MySQL has been started, you can use the MySQL command to connect (as if here or to use the new one), created a database, tested all OK, did not affect the previous MySQL.

The key point is that MySQL's profile my.cnf files are copied to the MySQL installation directory's var folder (the folder that MySQL uses to hold the database files) so that this profile is valid only for that server and does not affect the configuration file under the default/etc in the system. To prevent two mysqld from listening to the conflict, it is best to modify the socket and listening port in the configuration file (if connected over a network).

There is a problem with the configuration on Ubuntu. Ubuntu does not seem to replace the global configuration file with the new profile (MySQL read configuration file order is/etc/my.cnf-> database installation directory/my.cnf-> personal home directory/.my.cnf) so in the CREATE database (using Mysql_ install_db), you still need to specify the My.cnf file path (using the –defaults-file option). It is also required when you start the database. When you connect to a database using the MySQL command, you also need to specify a connected socket file, or my.cnf file.

If unknown option ' –skip-federated ' appears when you install the database, comment directly on the skip-federated line in your my.cnf file.

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.