Install and compile centos MySQL [Post]

Source: Internet
Author: User
Tags localhost mysql

Centos MySQL has been widely used but is constantly updated. Here we will introduce how to install and use centos MySQL to help you install and update centos MySQL. Install centos MySQL;

1] Extract
[Root @ localhost root] # cd/usr/local/MySQL/software
[Root @ localhost software] # ls
Mysql-4.0.16.tar.gz
[Root @ localhost software] # tar zxvf mysql-4.0.16.tar.gz

2] centos MySQL compilation and installation: It is worth noting that we need to install centos MySQL into our specified directory to ensure system security and optimization, we recommend that you store all the server software installed in the source code package in the // usr/local/MySQL directory. So here, we need to install the mysql-4.0.16 to the // usr/local/MySQL directory;
[Root @ localhost software] # cd
[Root @ localhost software] # cd mysql-4.0.16
[Root @ localhost mysql-4.0.16] #
. /Configure -- prefix = // usr/local/MySQL -- With-mysqld-user = beinan -- With-extra-charsets = all -- With-Unix-socket-Path =/ /usr/local/MySQL/var/MySQL. sock
[Note] A description of configure options:

Prefix = // usr/local/MySQL install the mysql-4.0.16 specified to the // usr/local/MySQL directory;
With-extra-charsets = all supports multiple languages;
With-Unix-socket-Path = // usr/local/MySQL/var/MySQL. sock: Specifies the location and file name of the online socket file after the MySQL server is started. That is, if the centos MySQL server is successfully started, you can see MySQL in the // usr/local/MySQL/var directory. sock file. If not, it must be that centos MySQL cannot be started.

With-mysqld-user = beinan: This enables the MySQL server to enable the common user beinan in the system to start the MySQL server. Of course, if you want to learn and use it, you can replace beinan with an existing common user in your system. For example, if your system already has a user named Sir, replace beinan with sir. The advantage of starting MySQL with a common user is that the centos MySQL process will die and automatically exit. Of course, the root user can do the same, but sometimes some processes in centos MySQL are dead, but they will not exit automatically, and the root user cannot kill themselves. Therefore, common users have the following benefits: The centos MySQL process is not dead, but does not quit;
[Root @ localhost mysql-4.0.16] # Make
[Root @ localhost mysql-4.0.16] # make install
In this case, centos MySQL installation is complete.

3] preparing centos MySQL installation is only the first step. We also need to prepare centos MySQL;
In general, centos MySQL is looking for the configuration file my. CNF, which is located in the/etc directory, so we have to put the file my. CnF in the/etc/directory. Let the centos MySQL Server find it when it is started. After we install centos MySQL, the preparation file should be in the // usr/local/MySQL/share/MySQL directory, the preparation file has a few, such as my-huge.cnf my-medium.cnf my-large.cnf my-small.cnf, websites with different traffic and server environments with different configurations must have different configuration files. Under normal circumstances, the preparation of my-medium.cnf files can meet most of our needs;

Go to the/usr/local/MySQL directory and check whether the directory has been installed ??
[Root @ localhost mysql-4.0.16] # cd // usr/local/MySQL/
[Root @ localhost MySQL] # ls
Bin include info lib libexec man mysql-test share SQL-Example
We copy the my-medium.cnf under the/usr/local/MySQL/share/MySQL directory as my. CNF to the/etc directory.
[Root @ localhost MySQL] # cp // usr/local/MySQL/share/MySQL/my-medium.cnf/etc/My. CNF

After doing this, you have to create a centos MySQL authorization table. Otherwise, the database cannot be started. Mysql_install_db. This command is used for this purpose. Commands installed in centos MySQL are installed in the directory // usr/local/MySQL/bin.
[Root @ localhost MySQL] # // usr/local/MySQL/bin/mysql_install_db
After running the mysql_install_db command, we can view // usr/local/MySQL and find a var directory. This directory is used to hold all database locations. For example, after we create the linuxsir database, there is a linuxsir directory in the // usr/local/MySQL/var directory. I should have understood this time.

4] Starting the centos MySQL server may be the easiest, but it cannot be too early, because sometimes permission errors may occur.
When the centos MySQL server is started, it should be mysql. server in the // usr/local/MySQL/share/MySQL directory.
The startup method is:
[Root @ localhost MySQL] # // usr/local/MySQL/share/MySQL. Server start
If it cannot be started, run/usr/local/MySQL/bin/mysqld_safe -- user = root to start it !!
Then, enter/usr/local/MySQL/share/MySQL. Server start to start the instance.
Now, set the password to 123456/usr/local/MySQL/bin/mysqladmin-u Root Password 123456.
If no error is returned, the description is correct.
Enter/usr/local/MySQL/bin/MySQL-u root-P to manage the installation of centos MySQL.

 

this article from the csdn blog, reprinted please indicate the source: http://blog.csdn.net/wingsing2010/archive/2010/09/09/5872871.aspx

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.