First uninstall the Mysql [root @ localhost ~] that comes with CentOS # Yumremovemysqlyuminstallgccyuminstallgcc-c ++ yuminstallcmake # Groupaddmysql [root @ local
First uninstall the Mysql that comes with CentOS
[Root @ localhost ~] # Yum removeMysql
Yum install gcc
Yum install gcc-c ++
Yum install cmake
Start to officially install Mysql
Add mysql users and user groups
[Root @ localhost ~] # Groupadd mysql [root @ localhost ~] # Useradd-g mysql
Download the mysql source code package/usr/local/src and decompress it.
[Root @ localhost ~] # Cd/usr/local/src/
[Root @ localhost src] # tar xzvf mysql-5.6.15.tar.gz
[Root @ localhost src] # cd mysql-5.6.15
Run cmake
[Root @ localhost mysql-5.6.15] # cmake.
-- Cocould NOT find Curses (missing: CURSES_LIBRARYCURSES_INCLUDE_PATH) CMake Error at cmake/readline. cmake: 82 (MESSAGE): Curses library not found. please installappropriate package, removeCMakeCache.txt and rerun cmake. on Debian/Ubuntu, package name islibncurses5-dev, on Redhat and derivates it is ncurses-devel. callStack (most recent call first): cmake/readline. cmake: 126 (FIND_CURSES) cmake/readline. Cmake: 216 (MYSQL_USE_BUNDLED_LIBEDIT) CMakeLists.txt: 250 (MYSQL_CHECK_READLINE) -- checking ing incomplete, errorsoccurred!
Remove CMakeCache.txt and rerun cmake. OnDebian/Ubuntu, package name is libncurses5-dev, on Redhat andderivates it is ncurses-devel.
[Root @ localhost mysql-5.6.15] # yum install ncurses-devel
Run cmake again
[Root @ localhost mysql-5.6.15] # cmake.-DENABLE_DOWNLOADS = 1
Warning: Bison executable not found in PATH
There is a warning and it is also solved. if there is a lack of Bison, install it.
[Root @ localhost mysql-5.6.15] # yum install bison
Run again, no error reported
[Root @ localhost mysql-5.6.15] # cmake.-DENABLE_DOWNLOADS = 1
Select the option you want to set based on the help information. you can skip this step and follow the default settings.
Start compilation and installation. it takes a little longer. you can take a cup of coffee for a while...
[Root @ localhost mysql-5.6.15] # make & make install
Go to the installation directory, change the ownership of the binary program to root, and change the description of the data directory to mysql user to update the authorization table.
[Root @ localhost mysql-5.6.15] # cd/usr/local/mysql/
[Root @ localhost mysql] # chown-R root.
[Root @ localhost mysql] # chown-R mysql.
[Root @ localhost mysql] # chgrp-R mysql.
[Root @ localhost mysql] # scripts/mysql_install_db -- user = mysql
Start mysql safely
[Root @ localhost mysql] #./bin/mysqld_safe -- user = mysql &
Disable mysql
[Root @ localhost mysql] #./bin/mysqladmin-u root shutdown-p
The default password is null.
Easy to call, set a soft link for mysql
[Root @ localhost ~] # Ln-s/usr/local/mysql/bin/mysql/usr/bin/mysql
There are three methods to set a password for the root account:
Use the set password statement
[Root @ localhost ~] # Mysql-u root
Mysql> set password for 'root' @ 'localhost' = PASSWORD ('newpwd '); mysql> set password for 'root' @ 'host _ name' = PASSWORD ('newpwd ')
Use the mysqladmin command line program
[Root @ localhost ~] # Mysqladmin-u root password "newpwd" [root @ localhost ~] # Mysqladmin-u root-h host_name password "newpwd"
UPDATE statement
[Root @ localhost ~] # Mysql-u root
Mysql> UPDATE mysql. user SET Password = PASSWORD ('newpwd')-> WHERE User = 'root'; mysql> flush privileges;
Other settings:
Set the option file and copy the configuration file to/etc.
[Root @ localhost mysql] # cp my. cnf/etc/mysql. cnf
If
Set auto-start
[Root @ localhost mysql] # cp support-files/mysql. server/etc/init. d/mysql [root @ localhost mysql] # chmod + x/etc/init. d/mysql
Now you can start and close Mysql through the service
[Root @ localhost ~] # Service mysql start [root @ localhost ~] # Service mysql shutdown
Basically, the installation is like this.