CentOS 6.5 compilation Install MySQL 5.5.40

Source: Internet
Author: User
Tags administrator password

Hello everyone, small gold today with you to practice compiling and installing MySQL5.5.40 source package.

We need to prepare some library files before we start.

[email protected] ~]# Yum install zlib-devel openssl-devel gcc-c++ gcc bison cmake ncurses-devel-y

Be sure to install these packages, small gold before the installation began to compile MySQL, stepped on a lot of pits, and later on the Internet to find the need for these files and management tools. Be sure to install it.

And if you make an error during compilation, be sure to do the following:

[Email protected] ~]# rm-f CMakeCache.txt

Then proceed with the installation.

After installation we will add the required accounts and directories for the MySQL database:

[Email protected] ~]# groupadd-r mysql[[email protected] ~]# useradd-g mysql-r-s/sbin/nologin mysql[[email protected ] ~]# ID mysql #确认用户 [[email protected] ~]# mkdir/usr/local/mysql-5.5.40-p #用来存放MySQL程序等 [[email protected] ~]# Mkdir/var /data/mysql-p #存放数据库文件 [[email protected] ~]# chown mysql:mysql/var/data-r

download MySQL source bundle: mysql-5.5.40.tar.gz Click I download MySQL5.5.40 source code

Upload to server after download

[Email protected] ~]# TAR-XVF mysql-5.5.40.tar.gz-c/usr/local/[[email protected] ~]# cd/usr/local/mysql-5.5.4

CMake some common options for compiling MySQL:

------------------------------------------------------------cmake mysql  compile and install:./configure -> &NBSP;CMAKE&NBSP, .... /configure --help -> cmake -lh -> ccmake .--------------------------- ---------------------------------Specify installation path for installation files common options-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/ MYSQL-DSYSCONFDIR=/ETC------------------------------------------------------------The default compiled storage engine includes: csv,  myisma, myisammrg, heap.  to install additional storage engines, you can use a compilation option similar to the following-dwith_innobase_storage_engine=1-dwith_archive _storage_engine=1-dwith_blackhole_storage_engine=1------------------------------------------------------------ To make it clear that a storage engine,  is not compiled, you can use an option similar to the following:-dwithout_<engine>_storage_engine=1 for example:-dwithout_example_storage_engine= 1-dwithout_federated_storage_engine=1------------------------------------------------------------to compile into other functions,  ,  such as SSL can use a library file or,  or not use a library file when compiling using a similar option.-dwith_readline=1-dwith_ssl=system-dwith_zlib=syStem-dwith_libwrap=0------------------------------------------------------------Other common options:-dmysql_tcp_port=3306- Mydql_unix_addr=/tmp/mysql.sock-denabled_local_infile=1-dextra_charsets=all-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dwith_debug=0-denable_profiling=1--------------------------------------------------- ---------

Okay, let's start compiling.

[Email protected] mysql-5.5.40]# CMake. -dcmake_install_prefix=/usr/local/mysql-5.5.40-dmysql_datadir=/var/data/mysql \ #数据库目录-dsysconfdir=/etc \ # Configuration file directory-dwith_innobase_storage_engine=1 \ #启用InnoDB存储引擎-dwith_archive_storage_engine=1 \ #启用ARCHIVE存储引擎-dwith_ blackhole_storage_engine=1 \ #启用黑洞存储引擎-dwith_readline=1-dwith_ssl=system \ #启用SSL协议-dwith_zlib=system \ # Enable zlib compression-dwith_libwrap=0-ddefault_charset=utf8 \ #设置字符集utf8-dmysql_nuix_addr=/tmp/mysql.sock-ddefault_collation= Utf8_general_ci

If the following information appears, then congratulations on your first phase of the configuration has been completed successfully

Do not be afraid of mistakes in the process, because your long experience is coming, usually because of the lack of a dependency on the package and problems, you can put your error information on the railway Google or Baidu to search.

.... (Omit 10,000 words here)--performing test have_ib_gcc_atomic_builtins--performing test have_ib_gcc_atomic_builtins-success-- Performing test have_ib_atomic_pthread_t_gcc--performing test have_ib_atomic_pthread_t_gcc-success--Check size of PTH read_t--Check size of pthread_t-done--performing test have_peercred--performing test have_peercred-success--Librar Y mysqlclient depends on oslibs-lpthread;z;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl--Configuring done-- Generating done--Build files has been written to:/usr/local/mysql-5.5.40

We continue to

[email protected] mysql-5.5.40]# make .... (10,000 words omitted here) Scanning dependencies of target udf_example[100%] Building C Object sql/cmakefiles/udf_example.dir/udf_ Example.c.olinking C shared module udf_example.so[100%] Built target udf_examplescanning dependencies of target my_safe_p rocess[100%] Building CXX Object Mysql-test/lib/my/safeprocess/cmakefiles/my_safe_process.dir/safe_ Process.cc.oLinking CXX executable my_safe_process[100%] Built target my_safe_process

If there is no error, we continue to

[email protected] mysql-5.5.40]# make install .... (omitted 10,000 words here)--Installing:/usr/local/mysql-5.5.40/man/man1/mysql_upgrade.1--Installing:/usr/local/mysql-5.5.40/man /man1/mysqlslap.1--Installing:/usr/local/mysql-5.5.40/man/man1/replace.1--Installing:/usr/local/mysql-5.5.40/ man/man1/mysql.1--Installing:/usr/local/mysql-5.5.40/man/man1/mysql_setpermission.1--Installing:/usr/local/ mysql-5.5.40/man/man1/mysql_secure_installation.1--Installing:/usr/local/mysql-5.5.40/man/man1/mysqlimport.1-- Installing:/usr/local/mysql-5.5.40/man/man8/mysqld.8

Install all OK after we configure permissions for the document

[[Email protected] mysql-5.5.40]# chown :mysql /usr/local/mysql-5.5.40 -r[[email  protected] mysql-5.5.40]# cd /usr/local/mysql-5.5.40/[[email protected]  mysql-5.5.40]# chmod +x scripts/mysql_install_db[[email protected] mysql-5.5.40]#  scripts/mysql_install_db --user=mysql --datadir=/var/data/mysql/  #执行初始化脚本 .... (Omit 10,000 words here) ./bin/mysqladmin -u root password  ' New-password ' ./bin/mysqladmin -u  root -h diguojin password  ' New-password ' alternatively you can run:./bin/ mysql_secure_installationwhich will also give you the option of  Removing the testdatabases and anonymous user created by default.   this isstrongly recommended for production servers. See the manual for more instructions. You cAn start the mysql daemon with:cd . ; ./bin/mysqld_safe &you  can test the MySQL daemon with mysql-test-run.plcd ./mysql-test  ;  perl mysql-test-run.plplease report any problems at http://bugs.mysql.com/

If you get the same information as above, congratulations, you're a step closer to success.

[Email protected] mysql-5.5.40]# ls/var/data/mysql/#看一下是否生成了文件mysql Performance_schema test# If that's the case, then let's go.

Create a service script

[email protected] mysql-5.5.40]# CP support-files/mysql.server/etc/rc.d/init.d/mysqld [[email protected] mysql-5.5.40]# chmod +x/etc/rc.d/init.d/mysqld #添加mysqld执行权限 [[email protected] mysql-5.5.40]# chkconfig--add mysqld # Add Boot Boot

Creating a configuration file

[[email protected] mysql-5.5.40]# mv /etc/my.cnf{,.bak}[[email protected]  mysql-5.5.40]# cp support-files/my-large.cnf /etc/my.cnf[[email protected]  mysql-5.5.40]# vim /etc/my.cnf# Find the following section [mysqld]port             = 3306socket          = / Tmp/mysql.sockskip-external-lockingkey_buffer_size = 256mmax_allowed_packet = 1mtable_open _cache = 256sort_buffer_size = 1mread_buffer_size = 1mread_rnd_buffer_size  = 4mmyisam_sort_buffer_size = 64mthread_cache_size = 8query_cache_size= 16m#  try number of cpu ' s*2 for thread_concurrencythread_concurrency =  8datadir= /var/data/mysql  #添加次行内容,  is the database file storage path: wq# save Exit [[email protected] mysql-5.5.40 ]# vim /etc/profile.d/mysql.Shexport path=/usr/local/mysql-5.5.40/bin: $PATH   #添加次行 [[email protected] mysql-5.5.40]#  . /etc/profile.d/mysql.sh  #导入环境变量

Okay, let's try to start the MySQL service.

[[Email protected] mysql-5.5.40]# service mysqld startstarting MySQL. [OK] [Email protected] mysql-5.5.40]#

Distance victory more and more close, refueling ^ ^


Then we'll configure the MySQL administrator password to initialize

[[email protected] mysql-5.5.40]# mysql  #使用客户端登录Welcome  to the MySQL  Monitor.  commands end with ; or \g.your mysql connection id  is 1Server version: 5.5.40-log Source distributionCopyright  (c)  2000,  2014, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement. #删除默认存在的账户mysql > delete from mysql.user where host!= ' localhost ';  Query OK, 4 rows affected  (0.00 sec) #修改root管理员账号密码mysql > update  mysql.usEr set password=password (' [email protected] ')  where user= ' root ';  Query OK,  1 row affected  (0.00 sec) rows matched: 1  changed: 1   warnings: 0# Update Database mysql> flush privileges; query ok, 0 rows affected  (0.00 sec) #看一下修改后的结果mysql > select user, password,host from mysql.user;+------+-------------------------------------------+-----------+|  user | password                                    | host      |+------+------------------------------------ -------+-----------+| root | *d7e39c3af517ec9ef7086223b036e0b4f22821f8 | localhost  | |       |                                             | localhost |+------+-------------------------------------------+-----------+2  rows in set  (0.00 sec) mysql> \qbye[[email protected] mysql-5.5.40] #

Then we'll be able to log in with the new password.

[Email protected] mysql-5.5.40]# mysql-u root-h localhost-penter Password: #输入刚才设置的密码Welcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 4Server version:5.5.40-log Source distributioncopyright (c)., Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql>

Well, MySQL has been installed successfully!! Thank you all!!

Yes, we forgot to import the development of the library file, OK soon good

[Email protected] mysql-5.5.40]# ln-sv/usr/local/mysql/include//usr/include/mysql #软连接到系统库中 [[email protected] mysql-5.5.40]# vim/etc/ld.so.conf.d/mysql.conf #编辑这个文件, and add the following path/usr/local/mysql-5.5.40/lib[[email protected] mysql-5.5.40]# ldconfig #重新加载库文件 [[email protected] mysql-5.5.40]# Ldconfig-p | grep MySQL #让我们来检查下是不是加载好了libmysqlclient_r. so.16 (libc6,x86-64) =/usr/lib64/mysql/libmysqlclient_ r.so.16libmysqlclient.so.18 (libc6,x86-64) =/usr/local/mysql-5.5.40/lib/ libmysqlclient.so.18libmysqlclient.so.16 (libc6,x86-64) =/usr/lib64/mysql/ Libmysqlclient.so.16libmysqlclient.so (libc6,x86-64) =/usr/local/mysql-5.5.40/lib/libmysqlclient.so

All right, everybody's working hard ~ MySQL5.5.40 Compilation and Installation complete

This article is from the "Imperial Gold Cai Yuan zi" blog, please be sure to keep this source http://diguojin.blog.51cto.com/5034509/1562325

CentOS 6.5 compilation Install MySQL 5.5.40

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.