1.2 tutorial backgroundStarting from MySQL, the compilation tool for MySQL source code installation starts from configure to cmake. The installation method is slightly different from that before MySQL. Here is a brief summary.
Code compilation and installation are the most error-prone and time-consuming. Sky recommends that you try to install it in multiple ways after learning one method.
Before installation, it is best to check for some basic software, such as make, GCC, Perl, libncurses5-dev, cmake-2.8.5, ncurses-devel, if not installed, use yum-y install gcc-c ++ make cmake bison ncurses-devel to install the complete command. Otherwise, an error is reported during compilation and installation.
1.3 install Cmake# Go To The Source Code directory
[Root @ localhost src] # cd/usr/local/src
# Download the Installation File
[Root @ localhost src] # wgethttp: // wwwNaNake.org/files/v2.8/cmake-2.8.5.tar.gz
# Decompress
[Root @ localhost src] # tar zxvfcmake-2.8.5.tar.gz
# Installation
[Root @ localhost src] # cd cmake-2.8.5
[Root @ localhost src] #./bootstrap
[Root @ localhost src] # gmake
[Root @ localhost src] # gmake install
# Return the source code directory
Cd ../
1.4cmake IntroductionCMake is short for "cross platform make. It is a cross-platform installation (Compilation) tool. You can use simple statements to describe the installation (compilation process) of all platforms ). He can output a variety of makefiles or project files and test the C ++ features supported by the compiler, similar to automake in UNIX.
Compared with the configure syntax
The installation options are compared as follows:
1.5 install bison-2.5# Download the Installation File
[Root @ localhost src] # wgethttp: // ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
# Decompress
[Root @ localhost src] # tar zxvfbison-2.5.tar.gz
# Installation
[Root @ localhost src] # cd bson-2.5
[Root @ localhost src] #./configure
[Root @ localhost src] # make
[Root @ localhost src] # make install
# Return the source code directory
Cd ../
1.6Mysql Installation# Create mysql users and groups
[Root @ localhost src] #/usr/sbin/groupaddmysql
[Root @ localhost src] #/usr/sbin/useradd-g mysql
[Root @ localhost src] # mkdir/usr/local/mysql # create a database directory
[Root @ localhost src] # mkdir/usr/local/mysql/data # create a database folder
# Put the source code in the directory/usr/local
# Decompress the package to the installation directory
[Root @ localhost src] # tar xvf mysql-5.5.27.tar.gz
[Root @ localhost src] # cd mysql-5.5.27
# Compile
[Root @ localhost mysql] # cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/usr/local/mysql/data/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS: STRING = utf8 \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/usr/local/mysql/data \
-DMYSQL_USER = mysql
# Installation
[Root @ localhost mysql] # make & makeinstall
1.7 link file 1.7.1 after installationLn-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib64/
# If you do not execute this step, the following error may occur during running:
Errorwhileloadingsharedlibraries: libmysqlclient. so.18: cannotopen#dobjectfile: Nosuchfileordirectory
1.7.2 set the path environment variableVi/etc/profile
# Add at the end of profile
Export PATH = "/usr/local/mysql/bin: $ PATH"
# Save
Source/etc/profile
1.7.3 configuration parameter fileCd support-files
Cp my-large.cnf/etc/my. cnf
# Edit my. cnf, add the following content, or modify the following on the original path:
Basedir =/usr/local/mysql
Datadir =/usr/local/mysql/data
Log-error =/usr/local/mysql/data/mysql_error.log
Pid-file =/usr/local/mysql/data/mysql. pid
Socket =/usr/local/mysql/data/mysql. socket // If yes, change the directory to the data directory of mysql, where/usr/local/mysql/data
1.7.4 Set permissions
[Root @ localhost mysql] # cd/usr/local/mysql
[Root @ localhost mysql] # chown-R mysql. # Add a space after mysql and modify the permission.
[Root @ localhost mysql] # chgrp-R mysql. # Add a space after mysql and modify the permission.
1.7.5mysql initial installationCd/usr/local/mysql/
[Root @ localhost mysql] # scripts/mysql_install_db \
-- Defaults-file =/etc/my. cnf \
-- Basedir =/usr/local/mysql \
-- User = mysql \
-- Force
If an error occurs like: 'Warning: The host' *** 'could not be looked up with resolveip'
Add the-force option during execution.
1.7.6 Modify permissions# Change the ownership of the installation directory to root, and change the ownership of the data directory to your runningMysqld user
Cd/usr/local/mysql
[Root @ localhost mysql] # chown-R root. # add space after root.
[Root @ localhost mysql] # chown-R mysqldata
1.8 Configuration Service# Configuration Service
Cd/usr/local/mysql/support-files
[Root @ localhost support-files] # cpmysql. server/etc/init. d/mysqld
[Root @ localhost support-files] # chmod + x/etc/init. d/mysqld
[Root @ localhost support-files] # chkconfig -- add mysqld # boot automatically
[Root @ localhost support-files] # chkconfig -- level 345 mysqld on
1.9 Start and Stop mysql[Root @ localhost ~] # Service mysqldstart
Starting MySQL SUCCESS!
[Root @ localhost ~] # Service mysqld stop
Shutting down MySQL... SUCCESS!
1.10 set the Mysql user account passwordAfter mysql is installed, two accounts are generated by default: one is root, and no password is set. You can log on to mysql from the local machine; the other is an anonymous account, with no account name or password. you can log on from the local machine, all connections without user names are assumed to be this account. This setting poses a security risk. You can change it according to the following steps.
1) modify the root password
Run the command:/usr/local/mysql/bin/mysqladmin-u root-p old password new password or use root to log on to the database
# Mysql-u root
Run after Logon
Mysql> set password for 'root' @ 'hostname' = password ('new password ');
Or execute
Mysql> update mysql. user setpassword = password ('new password ')
-> Where user = 'root' and host = 'hostname ';
If you do not know the hostname, run select host, user from mysql. user where user = 'root' first'
2) Delete Anonymous Users
Run
Mysql> delete from mysql. user where user = ''; delete records with empty user names
Mysql> delete from mysql. user where password = ''; delete records with empty passwords
3) after modifying the user permissions, execute
Mysql> flush privileges;
Because after MySQL is started, all user permissions are loaded to the memory, but some permission update operations are not refreshed to the memory, so that they will only take effect the next time they are started. If you directly update mysql. user to change the password; flush privileges forces MySQL to reload the permission, so that the modification will take effect immediately.
Summary: IT technologies are updated quickly. If you want to be an O & M expert, there are too many things to learn. For example, the above example is only an upgraded version. For O & M technicians, it will take several hours to study.
Attachment download: http://sky9896.blog.51cto.com/2330653/1682948