####################### Myslq #####################


############### 安装依赖 ################


shell> yum install -y cmake ncurses-devel

################ 新建 mysql user

shell> useradd -r -s /sbin/nologin mysql

shell> cd /opt/src/

shell> tar zxf /root/softs/mysql-5.6.13.tar.gz

shell> cd mysql-5.6.13/


########### cmake . 错误报警 #####################

error: Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)…


solve: shell> yum install -y ncurses-devel


Warning: Bison executable not found in PATH

solve: shell> yum install -y bison


warning: Googlemock was not found…

solve: shell> wget https://googlemock.googlecode.com/files/gmock-1.6.0.zip

shell> cd /opt/src/mysql-5.6.13/source_downloads/

shell> unzip /root/softs/gmock-1.6.0.zip

shell> cd gmock-1.6.0/

shell> ./configure

shell> make


Tip: 重新 camke . 需要 rm -f CMakeCache.txt 先


################### 编译安装 ##############################


shell> cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql \

-DMYSQL_UNIX_ADDR=/opt/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DMYSQL_DATADIR=/opt/mysql/data \

-DMYSQL_USER=mysql \

-DMYSQL_TCP_PORT=3609 \

-DENABLE_DOWNLOADS=1 \

-DWITH_DEBUG=0 \

-DSYSCONFDIR=/opt/mysql/etc \

-DWITH_EXTRA_CHARSETS:STRING=all .


shell> make

shell> make install


shell> cd mysql/

shell> chown -R mysql.mysql .

shell> scripts/mysql_install_db –user=mysql

shell> /usr/local/mysql/scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data/

shell> chown -R root .

shell> chown -R mysql data/


shell> in/mysqld_safe –user=mysql &


shell> mkdir -p /opt/mysql/etc/


shell> mv /opt/mysql/my.cnf /opt/mysql/etc/


shell> chgrp -R mysql /opt/mysql/etc


############# 安全设置 #############

shell> bin/mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we’ll need the current

password for the root user. If you’ve just installed MySQL, and

you haven’t set the root password yet, the password will be blank,

so you should just press enter here.


Enter current password for root (enter for none):

OK, successfully used password, moving on…


Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.


Set root password? [Y/n] Y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

… Success!


By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.


Remove anonymous users? [Y/n] Y

… Success!


Normally, root should only be allowed to connect from ‘localhost’. This

ensures that someone cannot guess at the root password from the network.


Disallow root login remotely? [Y/n] Y

… Success!


By default, MySQL comes with a database named ‘test’ that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.


Remove test database and access to it? [Y/n] Y

– Dropping test database…

… Success!

– Removing privileges on test database…

… Success!


Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.


Reload privilege tables now? [Y/n] Y

… Success!


All done! If you’ve completed all of the above steps, your MySQL

installation should now be secure.


Thanks for using MySQL!

Cleaning up…