How to install CentOS mysql

Source: Internet
Author: User
Tags localhost mysql mysql commands

Because CentOS linux is compatible with RHEL and stable for enterprise-level applications, and allows users to use it freely, it is widely used.
1] install and decompress CentOS mysql
[Root @ localhost root] # cd/usr/local/mysql/software
[Root @ localhost software] # ls
[Root @ localhost software] # tar zxvf mysql-4.0.16.tar.gz
2] CentOS mysql installation and CentOS mysql Compilation: It is worth noting in this place that we want to install the mysql-4.0.16 into the directory we specify for system and security optimization, we recommend that you store all the server software installed with 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 mysql server is started successfully, you can see mysql in the/usr/local/mysql/var directory. sock file. If not, it must be that CentOS mysql cannot be installed and started.
-- With-mysqld-user = beinan: This enables the mysql server to enable the CentOS mysql server as well as the common user beinan in the system. 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 CentOS mysql installation with a common user is that the mysql process will die and automatically exit. Of course, the root user can do the same, but sometimes some processes of CentOS mysql installation are dead, but will not automatically exit, and the root user will not be able to kill it. 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
The installation is complete.
3] CentOS mysql preparation: Installation is only the first step. We also need to install corresponding configurations for CentOS mysql;
In general, the configuration file my. cnf is located in the/etc directory for CentOS mysql installation. Therefore, we need to put the file my. cnf in the/etc/directory. Let the CentOS mysql Server find it when it is started.
After our CentOS mysql installation, the preparation file should be in the/usr/local/mysql/share/mysql directory, the preparation file has several, 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 MySQL authorization table. Otherwise, the database cannot be started. Mysql_install_db. This command is used for this purpose. CentOS mysql commands are installed in the/usr/local/mysql/bin directory.
[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, we have the linuxsir directory in the/usr/local/mysql/var directory. I should have understood this time.
4] Start the CentOS mysql Server, Maybe this is the easiest thing to do, but it cannot be too early, because sometimes there will be permission errors.
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.

Related Article

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: 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.