MySQL Installation documentation

Source: Internet
Author: User

Yum-y install cmake make ncurses-devel gcc gcc-c++ Bison perl

Create MySQL users and user groups

/usr/sbin/groupadd MySQL
/usr/sbin/useradd-g MySQL MySQL

Unzip

Tar zxvf mysql-5.6.12.tar.gz
CD mysql-5.6.12

MySQL5.5 Previous version is configure is now CMake, the format is slightly different, the following uses a newline character, if not the newline character on the same line.

CMake. -dcmake_install_prefix=/usr/local/webserver/mysql \
-dsysconfdir=/usr/local/webserver/mysql \
-dmysql_datadir=/data/mysql/3306/data \
-dextra_charsets=all \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-denabled_local_infile=1 \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dmysql_unix_addr=/tmp/mysql.sock \
-dmysql_user=mysql

Compiling the installation

Make
Make install

Change directory owner to MySQL and create related directories

Chown-r Mysql:mysql/usr/local/webserver/mysql
Mkdir-p/data/mysql/3306/data/
Mkdir-p/data/mysql/3306/binlog/
Mkdir-p/data/mysql/3306/relaylog/
Chown-r mysql:mysql/data/mysql/

Initialize the database
/usr/local/webserver/mysql/scripts/mysql_install_db--basedir=/usr/local/webserver/mysql \
--datadir=/data/mysql/3306/data--user=mysql--defaults-file=/usr/local/webserver/mysql/my.cnf \
--explicit_defaults_for_timestamp

Delete the default profile and set boot boot

Rm-rf/etc/my.cnf
CD support-files/
CP Mysql.server/etc/init.d/mysqld
chmod +x/etc/init.d/mysqld
Chkconfig--add mysqld
Chkconfig mysqld on

Start MySQL

Service mysqld Start

Log in to MySQL and create a default user

Log in to MySQL
/usr/local/webserver/mysql/bin/mysql

Log in and then execute the following command on the MySQL command screen to create the root user and set the password to root (which can be set to a different value, of course)
GRANT all privileges on * * to ' root ' @ ' localhost ' identified by ' root ';
GRANT all privileges on * * to ' root ' @ ' 127.0.0.1 ' identified by ' root ';
Flush privileges;

The installation is complete!

Other optimization configurations can refer to the following practices:

Edit the MySQL configuration file vi/usr/local/webserver/mysql/my.cnf and enter the following configuration

#错误日志目录
Log-error =/data/mysql/3306/mysql_error.log
#二进制日志目录
Log-bin =/data/mysql/3306/binlog/binlog

#InnoDB Cache data Size (index, lock, insert buffer, data dictionary, etc.)
#推荐设置为物理内存的25%-50%
Innodb_buffer_pool_size = 1G

#InnoDB共享表空间初始化大小
Innodb_data_file_path = Ibdata1:1g:autoextend

#每次事务提交或事务外的指令都需要将日志写入硬盘, set to 1 more secure
Innodb_flush_log_at_trx_commit = 1

#InnoDB日志缓存
Innodb_log_buffer_size = 64M

Helpful when #InnoDB a lot of write operations
Innodb_log_file_size = 256M

#启用InnoDB的status file
Innodb_status_file = 1

#最大连接数
max_connections = 100

#最大连接错误次数
Max_connect_errors = 10000

#设置慢查询时间
Long_query_time = 1

#设置临时表最大值, Max_heap_table_size and tmp_table_size to set the same size
Max_heap_table_size = 96M
Tmp_table_size = 96M

After modification, restart MySQL, if not restart successfully need to/data/mysql/3306/data directory of ibdata1 and ib_logfile* files to delete and then restart.

MySQL Installation documentation

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.