Mysql installation on linux II (mysql source code installation), mysql source code

Source: Internet
Author: User

Mysql installation on linux II (mysql source code installation), mysql source code

1. Download the corresponding mysql installation source package
Address: http://dev.mysql.com/downloads/mysql/5.1.html

2. If you have previously installed mysql, uninstall it.
Many linux distributions have pre-installed mysql, which is usually in the rpm format and the mysql version is relatively low (this may be due to compatibility testing considerations ). Therefore, before installing mysql on your own, uninstall the old mysql to ensure that our system is "pure ".
Run the following command to query the mysql installed in the system:
Rpm-qa | grep mysql
This command will fuzzy match the rpm installation package with the software name mysql. You can delete all the listed packages and delete them at one time. You can use the following script command:
For I in 'rpm-qa | grep "mysql" '; do rpm-e -- allmatches $ I; done
After executing the preceding command, if there are still stubborn elements that have not been deleted, delete them one by one using the following command:
Rpm-e -- allmatches packet-name
If the cyclic dependency problem is found, packet-name lists the cyclic dependency installation packages and deletes them all at once, for example:
[Root @ test root] # rpm-e -- allmatches mysql


Install the source code version of MySQL
3. Add a mysql user group
Groupadd mysql
 
4. Add a mysql user and specify it to the mysql user group.
Useradd-g mysql
 
5.decompress mysql-version.tar.gz
Gunzip | mysql-VERSION.tar.gz | tar-xvf-

6. Install mysql
Cd mysql-VERSION
. /Configure -- prefix =/usr/local/mysql -- with-charset = gbk -- with-extra-charsets = armscii8, ascii, big5, cp1250, cp1251, cp1256, cp1257, cp850, cp852, cp866, cp932, dec8, eucjpms, euckr, gb2312, gbk, primary, greek, hebrew, hp8, primary, latin1, latin2, latin5, latin7, macce, macroman, sjis, swe7, tis620, ucs2, ujis, utf8 -- with-plugins = innodb_plugin
Make
Make install
 
7. Copy the configuration file
Shells> cp support-files/my-medium.cnf/etc/my. cnf
 
8. Execute the mysql System database Initialization Script
Cd/usr/local/mysql
Bin/mysql_install_db -- user = mysql
 
9. Set the mysql installation directory permission and set the owner to mysql.
Chown-R mysql var
Chgrp-R mysql.
 
10. Start the mysql Application
/Usr/local/mysql/bin/mysqld_safe -- user = mysql &
 
11. Set the root password (Database DBA)
Bin/mysqladmin-u root password 'root'
 
12. log on to mysql
Bin/mysql-uroot-p
Enter password:
After successful logon, you will see:
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 229
Server version: 5.1.40-log MySQL Community Server (GPL)
 
Type 'help; 'or 'H' for help. Type 'C' to clear the current input statement.
 
Mysql>
 
Now that mysql has been installed, you can view the database, but you still need to do some work when using the database development and deployment:

1. Set the configuration file my. cnf

Copy my-***. cnf to/etc/my. cnf as required

2. Modify the default Character Set utf8

(1) Add default-character-set = utf8 under [client]
(2) Add default-character-set = utf8 under [mysqld]

# Skip Steps 3 and 4 without changing the storage engine
3. Start the InnoDB engine as follows:
1) Disable mysql services
2) modify my. ini
Remove the comment (#) before default-storage-engine = INNODB
Comment this line of skip-innodb (plus #)

4. Configure innodb Parameters
1). Find # Uncomment the following if you are using InnoDB tables
Remove all # Under innodb #

2). If the directory for installing mysql is not the default one, you need to modify
# The default installation directory of mysql is/usr/local/mysql/
# The default installation directory of the mysql tablespace directory is/usr/local/mysql/var/

Innodb_data_home_dir =/usr/local/database/mysql/var/
Innodb_log_group_home_dir =/usr/local/database/mysql/var/
3). Save and restart the mysql service.

5. Set system services

Enable mysql service when linux is started
Shell> cd/usr/local/mysql/
Shell> cp support-files/mysql. server/etc/init. d/mysql
Shell> chmod 777/etc/init. d/mysql
Shell> chkconfig -- add mysql
Shell> chkconfig -- level 35 mysql on
 
6. Restart the MySQL service.
Shell> service mysql restart
The specific parameters of the latest mysql source code compilation and Installation Method in Linux are described in the following section.

The following is the configuration experience of CentOS Linux 5:
Add a mysql account
Groupadd mysql
Useradd-r-g mysql
Installation is required before compilation.
Cmake-2.8.4 and bison-2.4.3
Decompress mysql-5.5.15.tar.gz after successful installation:
Open the terminal in the source code root directory and enter the following configuration parameters and press Enter.
Cmake-DCMAKE_INSTALL_PREFIX =/etc/mysql \
-DMYSQL_UNIX_ADDR =/etc/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/var/mysql/data \
-DMYSQL_USER = mysql

After successfully executing the following command, you will be able to see it at the end (/root/Desktop/is your source code directory, depending on your situation)
-- Build files have been written to:/root/Desktop/mysql-5.5.15

Run make to install:
Make
Make install
The following steps are not described in detail:
Cd/mysql
Chown-R mysql: mysql.
Scripts/mysql_install_db -- user = mysql
Chown-R root.
Chown-R mysql data
Cp./support-files/my-small.cnf./my. cnf
Cp support-files/mysql. server mysql; chmod + x mysql
Chown-R mysql: root.
./Mysql start
./Bin/mysqladmin-u root-p 123456

Add startup Service
Chkconfig -- add mysql
Chkconfig mysql on
Service mysql start

If everything goes well, it will be done here. I wish you success.

Why should I create a mysql user first when installing mysql using the source code in linux?

For security .. The advantage of doing so is that when someone else gets rid of your database, you can only get the mysql permission of the system, but not the entire root permission .. .. It is much safer .. Not only does mysql, such as apache, and many other software have such settings .. It indicates that such software is good software ..

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