Install mysql-5.5.36.tar.gz in centos 7
1. Install cmake to compile
Yum install cmake
2. Download
Download mysql-5.5.36.tar.gz
Tar xvf mysql-5.5.36.tar.gz
Cd mysql-5.5.36
3. Compile the source code
Cmake \
-DCMAKE_INSTALL_PREFIX =/data/mysql \
-DMYSQL_DATADIR =/data/mysql/data \
-DSYSCONFDIR =/etc \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DMYSQL_UNIX_ADDR =/var/lib/mysql. sock \
-DMYSQL_TCP_PORT = 3306 \
-DENABLED_LOCAL_INFILE = 1 \
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
-DEXTRA_CHARSETS = all \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci
Make & make install
For compilation parameters, see http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.
4. Add users and user groups
Groupadd mysql -- add a user group
Useradd-r-group mysql -- add a user and specify the user group
Chown-R mysql: mysql/data/mysql -- Grant user and User Permissions
5. Install the database
Su mysql
Cd/data/mysql/scripts
./Mysql_install_db -- user = mysql -- basedir =/data/mysql -- datadir =/data/mysql/data
6. Configuration File
Cd/data/mysql/support-files
Cp my-default.cnf/etc/my. cnf -- mysql configuration (If your version does not have a my-defualt.cnf file, depending on your memory
Select one of the my-huge.cnf, my-large.cnf, my-medium.cnf, my-small.cnf)
Cp mysql. server/etc/init. d/mysql -- configure the service to the startup directory
7. Modify two values in the configuration file
Vim/etc/init. d/mysql
Basedir =/data/mysql
Datadir/data/mysql/data
8. Configure Environment Variables
Vim/etc/profile
Export MYSQL_HOME =/data/mysql
Export PATH = $ MYSQL_HOME/bin: $ PATH
Save and exit. Refresh source/etc/profile.
9. Start mysql
Service mysql start
10. log on to mysql and configure the root password.
Mysqladmin-u root password 'your _ password' -- change the password
Mysql-u root-p -- Password required for logging on to mysql
Mysql> grant all privileges on *. * TO 'root' @ '%' identified by 'your _ password' with grant option; // Allow Remote Login
Mysql> flush privileges; -- refresh the permission
Mysql> exit
11. How to retrieve the lost Password
Cd $ MYSQL_HOME
./Bin/mysqld_sale -- basedir =/data/mysql -- datadir =/data/mysql/data -- skip-grant-tables & -- log in with sale
Mysql-u root mysql
UPDATE user SET password = PASSWORD ('new _ password') WHERE user = 'root'; -- change the password
Flush privileges; -- refresh