Compile and install MySQL

Source: Internet
Author: User
Tags mysql version

Reference: Http://www.centoscn.com/CentosServer/www/2015/0422/5245.html installation mysql5.6.17

1. Create the owning user and user group for MySQL according to the standard

创建群组groupadd mysql创建一个用户,不允许登陆和不创主目录 useradd -s /sbin/nologin -g mysql -M mysql检查创建用户tail -1 /etc/passwd

2.MySQL starting with version 5.5, the compile configuration via./configure has been canceled and replaced by the CMake tool. Therefore, we first need to compile and install the CMake tool in the system source code.

wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz tar zxvf cmake-2.8.12.2.tar.gz cd cmake-2.8.12.2 ./configure make && make install

3. Use CMake to compile the installation mysql5.6.17

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gztar zxvf mysql-5.6.17.tar.gzcd mysql-5.6.17cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DWITH_DEBUG=0 -DWITH_SSL=systemmake && make install

Modify/usr/local/mysql Permissions

chmod +w /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql

About the MY.CNF configuration file:

When starting the MySQL service, will be in a certain order to search my.cnf, first in the/etc directory to find, can not find the search "$basedir/my.cnf" is the installation directory/usr/local/mysql/ MY.CNF, this is the default location for the new MySQL configuration file! Note: After the minimum installation of the CentOS 6.x operating system is complete, there will be a my.cnf in the/etc directory, which will need to be renamed to a different name. such as:/etc/my.cnf.bak, otherwise, the file will interfere with the correct configuration of the source installed MySQL, causing the failure to start. Since we have uninstalled the MYSQ library after the minimum installation is complete, there is no need to operate it.

Enter the Support-files directory

cd support-files/如果还有my.cnf请备份mv /etc/my.cnf /etc/my.cnf.bak如果愿意也可以复制配置文件到etc下cp my-default.cnf /etc/my.cnf

Execute the initialization configuration script, create the system's own database and table, note the path of the configuration file

/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

Copy the MySQL installation directory under the Support-files service script to the INIT.D directory

#拷贝脚本cp support-files/mysql.server /etc/init.d/mysqld#赋予权限chmod +x /etc/init.d/mysqld

Set boot up

chkconfig mysqld on启动MySQLservice mysqld start或者/etc/init.d/mysql start

Mysql5.6.x after successful startup, Root does not have a password, we need to set the root password. Before setting, we need to set path, or we can't call MySQL directly.

修改/etc/profile文件vi /etc/profile在文件末尾添加PATH=/usr/local/mysql/bin:$PATHexport PATH

Let the configuration take effect immediately

source /etc/profile

Login test, the default is no password, direct return to enter

mysql -uroot -p

Set MySQL password

/usr/local/mysql/bin/mysqladmin -uroot -p password ‘你的密码‘

Log in to command line mode

mysql -uroot -p

View User

select user,host from mysql.user;

Remove unnecessary users

drop user ""@localhost;drop user ""@c65mini.localdomain; drop user [email protected]; drop user [email protected]‘::1‘;

Grant the account Remote access permission

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘127.0.0.1‘ IDENTIFIED BY ‘你的密码‘ WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘localhost‘ IDENTIFIED BY ‘你的密码‘ WITH GRANT OPTION;GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘c65mini.localdomain‘ IDENTIFIED BY ‘你的密码‘ WITH GRANT OPTION;

About removing MySQL from the default root user reference: http://blog.chinaunix.net/uid-16844903-id-3377690.html

Some other information query: check MySQL version

mysql -uroot -p"密码" -e "select version();"

Verifying the MySQL installation path

ls -ld /usr/local/mysql/
 

Compile and install MySQL

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.