Build and install mysql5.1 and mysql5.5 under CentOS

Source: Internet
Author: User
Tags check character file permissions

mysql5.1.60 Compiling and installing
1, TAR-ZXVF mysql*
2. Before/configure
./configure--prefix=/home/shk/mysql-5.1.60 \
--enable-local-infile \
--with-unix-socket-path=/home/shk/mysql-5.1.60/var/mysql.sock \
--with-tcp-port=5506 \
--enable-thread-safe-client \
--with-mysqld-user=root \
--with-extra-charsets=gb2312,big5,gbk,binary,ascii,latin1 \
--with-charset=utf8 \
--with-federated-storage-engine \
--with-partition

Note: Error checking for termcap functions Library ... configure:error:nocurses/termcap library found when performing "make clean" failure.
Execute the./configure command and execute the command code:
./configure--prefix=/usr/share/mysql/-with-charset=utf8-with-extra-charsets=all–with-named-curses-libs=/usr/ lib/libncursesw.so.5 (last command can be omitted)

Error occurred: No curses/termcap Library found or seethe install manual chapter in the reference
Yum–y install gcc yum install Ncurses-devel
When installing GCC, the error libstdc++-devel* is not installed, manually the next libstdc++-devel*.rpm wrapper,
is installed with RPM libstdc++-devel*. RPM times Wrong: error:failed dependencies,
Command: RPM-IVH libstdc++*.rpm--nodeps--force
3, make
If error, reduce configure
4, make install
5, build MySQL startup file
#chown-R root:mysql/usr/local/mysql
#chown-R mysql:mysql/usr/local/ Mysql/data
#chown-R mysql:mysql/usr/local/mysql/lib

#cd/usr/local/mysql/bin/
#./mysql_install_db--user=mysql
#cp/usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
#cp/usr/local/mysql/share/mysql/my-medium.cnf/etc/my.cnf
6, start MySQL
#/usr/ Local/mysql/share/mysql/mysql.server start
7, download the compiled and installed MySQL
in the source file: Make uninstall
mysql5.5.31 compile installation
1, Download install compile MySQL source required library
sudo apt-get install build-essential libncurses5-dev cmake
2, add MySQL user group and user
Groupadd MySQL
useradd-g MySQL MySQL
3, create MySQL software installation directory and data storage directory
Mkdir-p/opt/mysql #MySQL安装目录
Chown-r mysql:mysql/opt/m Ysql
mkdir-p/data/mysql #MySQL数据存放目录
mkdir-p/data/mysql/data #存放数据
mkdir-p/data/mysql/log #存放日志
Mkdir-p/data/mysql/tmp #存放临时文件
Chown-r mysql:mysql/data/mysql

4. CMake Compile and install MySQL
TAR-ZXVF mysql-5.6.13.tar.gz
CD mysql-5.6.13
CMake. -dcmake_install_prefix=/opt/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/opt/mysql-ddefault_charset=utf8- Ddefault_collation=utf8_general_ci-dextra_charsets=all-denabled_local_infile=1
Make
Make install
Parameter description:
-dcmake_install_prefix=/opt/mysql//Specify installation directory
-dinstall_datadir=/data/mysql//Specify Data storage directory
-dsysconfdir=/opt/mysql//Specify the profile directory (this example has a configuration file of/opt/mysql/my.cnf)
-ddefault_charset=utf8//Specify character Set
-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Specify check character
-dextra_charsets=all//Install all extended character sets
-denabled_local_infile=1//Allow import of data from local
After successful execution of the above steps, the MySQL software has been successfully installed into the/opt/mysql directory.

5. Edit the configuration file my.cnf
[Client]
Port= 3306
Socket =/opt/mysql/run/mysql.sock

[MySQL]

[Mysqld_safe]
Pid-file =/opt/mysql/run/mysqld.pid
Socket =/opt/mysql/run/mysql.sock
Nice= 0

[Mysqld]

# # # # Baes Dir # #
Basedir =/opt/mysql
DataDir =/data/mysql/data
Tmpdir =/data/mysql/tmp
Socket =/opt/mysql/run/mysql.sock
User=mysql
# # # Base Configure Info # # # #
Port = 3306

Skip-external-locking
#
# Instead of skip-networking The default is now-listen only on
# localhost which are more compatible and are not less secure.
#bind-address= 127.0.0.1
#
# * Fine Tuning
#
Key_buffer= 16M
max_allowed_packet= 16M
thread_stack= 192K
Thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# The first time they is touched
Myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit= 1M
Query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware the this-log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file =/var/log/mysql/mysql.log
#general_log = 1
Log-error =/data/mysql/log/alert.log
Slow_query_log_file=/data/mysql/log/slow.log
# Here's can see queries with especially long duration
#log_slow_queries =/var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes

# # # Binary log && Relay Log # # # #
#binlog_format = ' MIXED '
Log-bin =/data/mysql/log/mysql-bin
Log-slave-updates = 1
Relay-log =/data/mysql/log/mysqld-relay-bin
Relay-log-index =/data/mysql/log/mysqld-relay-bin.index
Master-info-file =/data/mysql/log/master.info
Relay-log-info-file =/data/mysql/log/relay-log.info
Max_binlog_size = 100M

[Mysqldump]
Quick
Quote-names
max_allowed_packet= 16M

[MySQL]
#no-auto-rehash# faster start of MySQL but no tab completition

[Isamchk]
Key_buffer= 16M
6. Create a database
/opt/mysql/scripts/mysql_install_db--user=mysql
The above building statement will generate the corresponding data file and log file according to the data file directory and log file directory set in My.cnf, and create the system database (such as Mysql,test,information_schema,performance_schema).
7. Start MySQL
/opt/mysql/support-files/mysql.server start
After successful startup, you can log in as root (the default root user does not have a password)
/opt/mysql/bin/mysql-u Root
See if you can sign in
8. Set Root password
mysqladmin-u root password ' 123456a? '
Mysql-uroot-p
GRANT all privileges on * * to ' root ' @ '% ' identified by ' 123456a? ' With GRANT OPTION;

9. Finally, add MySQL to the system startup and boot
In the/etc/profile file, add
Export path= $PATH:/opt/mysql/bin
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/INIT.D/MYSQLD #把Mysql加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Update-rc.d-f mysqld Defaults #加入开机启动

Error and resolution:
1. Error message: The server quit without updating PID file
FIX: Configuration information may be too many, appropriate to delete parameters
2, attention to file permissions issues

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.