1. Download the corresponding MySQL installation source code package
Address: http://dev.mysql.com/downloads/mysql/5.1.html
2. If you have ever installed, uninstall the unused old installed MySQL
Because there are a lot of Linux distributions, the corresponding MySQL is preinstalled, usually in RPM form, and MySQL version number is lower (this may be due to compatibility test). So before you install MySQL yourself, please uninstall these old MySQL, to ensure the "pure" of our system.
Use the following command, for example, to query for MySQL installed in the system:
Rpm-qa|grep MySQL
This command will blur the matching software name with MySQL RPM installation package, the list of these can delete them, once deleted, you can use such as the following script command:
For i in ' Rpm-qa | grep "MySQL"; Do rpm-e--allmatches $i; Done
After running the above command. Suppose there are still stubborn molecules that have not been removed. That's one. Use the following command to delete:
RPM-E--allmatches Packet-name
Assuming a circular dependency problem is found, then packet-name lists the installation packages for which these loops are dependent. All-in-one deletions, such as:
[[email protected] root]# rpm-e--allmatches MySQL
Install the source version number of MySQL
3. Join the MySQL user group
Groupadd MySQL
4. Join the MySQL user and assign to the MySQL user group
useradd-g MySQL MySQL
5. Unzip the 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,GEOSTD8,GREEK,HEBREW,HP8,KEYBCS2,KOI8R, Koi8u,latin1,latin2,latin5,latin7,macce,macroman,sjis,swe7,tis620,ucs2,ujis,utf8--with-plugins=innodb_plugin
Make
Make install
7. Copy the configuration file
shell> CP support-files/my-medium.cnf/etc/my.cnf
8. Run the MySQL system database initialization script
Cd/usr/local/mysql
bin/mysql_install_db--user=mysql
9. Set MySQL installation folder permissions, set owner to MySQL
Chown-r mysql var
Chgrp-r MySQL.
10. Start the MySQL app
/usr/local/mysql/bin/mysqld_safe--user=mysql &
11. Setting up the Rootpassword (DBA for the database)
Bin/mysqladmin-u root password ' root '
12. Log in to MySQL
Bin/mysql-uroot-p
Enter Password:
Login success 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>
At this point, MySQL has been installed and able to view the database, but in the formal use of database development and deployment of the need to do some work:
1. Setting the configuration file my.cnf
Copy my-***.cnf to/etc/my.cnf according to requirements
2. Change the default character set UTF8
(1). Add Default-character-set=utf8 under [client]
(2). [Mysqld] Add Default-character-set=utf8
#不修改存储引擎的话. 3, 4 steps can be skipped
3. The method for starting the InnoDB engine is as follows:
1) Turn off the MySQL service
2) Change My.ini
Remove the gaze (#) before the Default-storage-engine=innodb
Will skip-innodb this line of gaze (plus #)
4. Configuring InnoDB Parameters
1). Find the # Uncomment the following if you are using InnoDB tables
Get rid of all the innodb_* #
2). Assume that the folder where MySQL is installed is not the default. You need to change
# mysql default installation folder is/usr/local/mysql/
# mysql default tablespace folder installation folder 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). Restart the MySQL service after saving.
5. Setting Up System Services
Start the MySQL service when Linux starts
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 MySQL on
6. Restart the MySQL service
shell> Service MySQL Restart
MySQL installation on Linux II (MySQL source code installation)