Compile and install MySQL under the same account
Compile and install MySQL under the same account
Check whether the old version exists:
Rpm-qa | grep mysql
Uninstall the old version:
Rpm-e mysql # normal deletion Mode
Rpm-e -- nodeps mysql # Strong deletion mode. If the above command is used to delete other dependent files, you can use this command to forcibly delete them.
Install the package required for compiling code
Yum-y install make
Yum-y install gcc-c ++
Yum-y install cmake
Yum-y install bison-devel
Yum-y install ncurses-devel
Decompress the source code:
Tar-zxvf mysql-5.5.20.tar.gz
Cd mysql-5.5.20
Cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_DATADIR =/usr/local/mysql/data \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DEXTRA_CHARSETS = all \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_UNIX_ADDR =/var/lib/mysql. sock \
-DSYSCONFDIR =/etc \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DMYSQL_TCP_PORT = 3306 \
-DENABLED_LOCAL_INFILE = 1 \
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
The bold part is required.
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
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
Check whether the compilation is completed correctly
Echo $? # Return 0, indicating that the operation is completed correctly
Compile and install
Make & make install
Echo $? # Check whether the installation is successful.
Configure mysql
Run the following command to check whether mysql users and user groups exist:
Cat/etc/passwd view User List
Cat/etc/group view User group list
Create if no
Groupadd mysql
Useradd-g mysql
Configure Directory Permissions
Cd/usr/local/lamp/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
Add the mysql startup service to the System Service
Cp support-files/my-medium.cnf/etc/my. cnf
Create a table for the system database
Cd/usr/local/lamp/mysql
Scripts/mysql_install_db
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 effective File
Start MySQL
Cp support-files/mysql. server/etc/init. d/mysqld
Chkconfig-add mysqld
Service mysqld start -- start MySQL
Modify the password of the root user of MySQL and enable remote connection.
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
If remote connection is not available, disable the firewall.
/Etc/rc. d/init. d/iptables stop
When a new user cannot log on to the database, log on to the database and delete the empty user.
Delete from user where user is null;
Delete from user where user = '';
Flush privileges;
Compile and install MySQL 5.6.14 in CentOS 6.4
This article permanently updates the link address: