Installation environment: centos 5.5
Installation version: mysql-5.5.8.tar.gz
1. Install the cmake compiler.
1) download cmake
# Cd/usr/local/src
# Wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
2) decompress cmake
# Tar-zvxf cmake-2.8.4.tar.gz
3) Configure Compilation
# Cd cmake-2.8.4
# Yum-y install gcc
# Yum-y install gcc-C ++
# Yum-y install ncurses-devel
#./Configure
# Make
# Make install
2. Install MySQL
1) download MySQL.
# Cd/usr/local/src
# Wget http://sdk.ruiya.com/linux/mysql-5.5.9.tar.gz
2) add necessary groups and owners
# Groupadd MySQL
# Useradd-r-g MySQL
3) decompress MySQL
# Tar-zvxf mysql-5.5.9.tar.gz
4) Configure Compilation
To reinstall MySQL, delete my. CNF, for example, Rm-RF/etc/My. CNF.
# Mkdir/usr/local/MySQL
# Mkdir/usr/local/MySQL/Data
# Cd/usr/local/src/mysql-5.5.9
# Cmake .\
-Dcmake_install_prefix =/usr/local/MySQL \
-Dinstall_datadir =/usr/local/MySQL/data \
-Ddefault_charset = utf8 \
-Ddefault_collation = utf8_general_ci \
-Dextra_charsets = all \
-Denabled_local_infile = 1
Parameter description:
-Dcmake_install_prefix =/usr/local/MySQL // installation directory
-Dinstall_datadir =/usr/local/MySQL/Data // database storage directory
-Ddefault_charset = utf8 // use the utf8 character
-Ddefault_collation = utf8_general_ci // check the character
-Dextra_charsets = All // install all extended character sets
-Denabled_local_infile = 1 // allow local data import
# Make
# Make install
Note:
During re-compilation, you need to clear the old object file and cache information.
# Make clean
# Rm-F cmakecache.txt
# Rm-RF/etc/My. CNF
4) Set Directory Permissions
# Cd/usr/local/MySQL
# Chown-r root: mysql. // set the owner of all files in the current directory to root and the owner group to MySQL.
# Chown-r MYSQL: MySQL DATA
5) configuration file
# Cp support-files/my-medium.cnf/etc/My. CNF // This configuration is only suitable for small memory systems (32 m-64 m)
Open the following comment::
Innodb_data_home_dir =/usr/local/MySQL/Data
Innodb_data_file_path = ibdata1: 10 m: autoextend
Innodb_log_group_home_dir =/usr/local/MySQL/Data
Innodb_buffer_pool_size = 16 m
Innodb_additional_mem_pool_size = 2 m
Innodb_log_file_size = 5 m
Innodb_log_buffer_size = 8 m
Innodb_flush_log_at_trx_commit = 1
Innodb_lock_wait_timeout = 50
Add default Character Set:
[Client]
Default-character-set = utf8 // Add encoding support
[Mysqld]
Default-character-set = utf8 // Add encoding support
Max_connections = 10000 // adjusted based on server performance
Basedir =/usr/local/MySQL// Set the installation directory so that the installation directory can be correctly run to/etc/rc. d/init. d/MySQL start at system startup.
6) create a table for the system database
# Cd/usr/local/MySQL
# Scripts/mysql_install_db -- user = MySQL
7) set the permission to start
Set Environment Variables:
# Vi/root/. bash_profile
Add the following parameter in Path = $ path: $ home/bin:
Path = $ path: $ home/bin:/usr/local/MySQL/lib
# Source/root/. bash_profile
Start MySQL manually:
# Cd/usr/local/MySQL
#./Bin/mysqld_safe -- user = MySQL & // start MySQL, but cannot stop
Startup logs are written in this file:/usr/local/MySQL/data/localhost. Err
Disable MySQL Service
# Mysqladmin-u root-P shutdown // the root user of MySQL has not configured a password, so it is null.
Start MySQL using scripts:
# Ln-S/usr/local/MySQL/support-files/MySQL. Server/usr/local/MySQL
// It must be noted that it is stored in the MySQL directory, not the bin directory.
# Cp/usr/local/MySQL/support-files/MySQL. Server/Usr/local/MySQL
# Mysql. Server start // start MySQL
# Mysql. server stop // stop MySQL
Start MySQL during boot:
# Ln-S/usr/local/MySQL/support-files/MySQL. Server/etc/rc. d/init. d/MySQL
# Ln-S/Usr/local/MySQL/MySQL. Server/etc/rc. d/init. d/MySQL
# Cd/etc/rc. d/init. d
# Chkconfig -- add MySQL // configure whether to automatically start. chkconfig -- del MySQL can be deleted.
# Chmod + x/etc/rc. d/init. d/MySQL // Add the execution permission
Tips
Linux running level:
It is divided into eight running levels, 7 of which are commonly used. You can set it in the/etc/inittab file.
0-Halt
1-Single User Mode
2-multiuser, without NFS
3-full multiuser Mode
4-unused
5-X11
6-Reboot
Default Value: ID: 3: initdefault:
Each category has its own folder at the dynamic level, for example:
/Etc/rc. d/rc3.d indicates that the configuration with the running level of 3 is stored in this file.
# Chkconfig -- list | grep MySQL // check whether it is set to self-start
MySQL 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable
Indicates that MySQL is automatically started at runtime Level 2, 3, 4, and 5.
You can also manually configure your own startup:
This may occur. If you try to run ../init. d/MySQL start in the/etc/rc. d/rc3.d directory, you may receive the following error:
Starting mysqlcouldn't find MySQL Server (./bin/mysqld_safe [Failed]
It can be seen that mysql. Server references a relative path./bin/mysqld_safe, which leads to failure.
In this way, we can directly add the startup script in the RC. Local file:
# Chkconfig -- del MySQL
# Cd/etc/rc. d
# Vi RC. Local // Add:/usr/local/MySQL/bin/mysqld_safe -- user = MySQL &
Solution: in the/etc/My. CNF configuration file, add:
Basedir =/usr/local/MySQL
8 ),Modify the password of the root user of MySQL:
# Mysql-u root MySQL
Mysql> use MySQL;
Mysql> DESC user;
Mysql> grant all privileges on *. * to root @ "%" identified by "root ";// Add the remote connection capability to the root user.
Mysql> Update user SET Password = PASSWORD ('Xxxxxx') Where user = 'root ';
Mysql> select host, user, password from user where user = 'root ';
Mysql> flush privileges;
Mysql> exit
Log On again: mysql-u root-P
9) add soft links
# Ln-S/usr/local/MySQL/lib/MySQL/usr/lib/MySQL
# Ln-S/usr/local/MySQL/include/MySQL/usr/include/MySQL
Note:
<1> mysql5.5 uses InnoDB as the storage engine by default, so you can leave it unspecified.Dwith_myisam_storage_engine Value
Refer:
How to enable remote logon for the root account in MySQL
Mysql> grant all privileges on *. * to root @ "%" identified by "root ";
Note that the password of % is different. You can use update user SET Password = PASSWORD ('Xxxxxx') Where user = 'root'; modify.
Check whether the firewall is disabled or add exceptions.
#/Etc/rc. d/init. d/iptables stop
Disable or enable the firewall on Linux/centos
Export the database to generate an SQL script
Mysqldump-H 192.168.200.18-u root-P testdb> testdb. SQL
<2> test the MySQL daemon.
# Cd/usr/local/MySQL-test;
# Perl mysql-test-run.pl.
<3> Notes:
To Start mysqld at boot time you have To Copy
Support - Files / MySQL. Server To The Right Place For Your system
Please remember To Set A password For The MySQL Root User !
To Do so, start the server, Then Issue the following commands:
/ USR / Local / MySQL / Bin / Mysqladmin - U Root Password ' New-Password '
/ USR / Local / MySQL / Bin / Mysqladmin - U Root - H localhost Password ' New-Password '
Alternatively you can run:
/ USR / Local / MySQL / Bin / Mysql_secure_installation
Which will also give you Option Of Removing the test
Databases And Anonymous User Created By Default . This Is
Strongly recommended For Production servers.
See the manual For More instructions.
You can start the MySQL daemon With :
CD / USR / Local / MySQL; / USR / Local / MySQL / Bin / Mysqld_safe &
You can test the MySQL daemon With MySQL - Test - Run. pl
CD / USR / Local / MySQL / MySQL - Test; Perl MySQL - Test - Run. pl
Please report Any Problems With The / USR / Local / MySQL / Scripts / Mysqlbug script!
Refer:
How to solve mysql5.5.8 Installation Problems