Mysql installation II on linux (mysql source code installation) _ MySQL
Source: Internet
Author: User
1 download the corresponding mysql installation source package address: http: devmysqlcomdownloadsmysql51html2 if you have installed it before, Uninstall unused installed mysql because many linux releases, the corresponding mysql is pre-installed, generally 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
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 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.