Linux under source installation compile MySQL database

Source: Internet
Author: User
Tags mysql commands

            mysql is an open source code The relational database management system (RDBMS), MySQL database system using the most common database management language- Structured Query Language (SQL) for database management.


Here are the specific steps of MySQL database source installation:

Environment: redhat6.5

Required Packages: mysql-boost-5.7.11.tar.gz

cmake-2.8.12.2-4.el6.x86_64.rpm #要求cmake版本2.8 and above

######### #mysql ############

To download the installation package and unzip it:

mysql-boost-5.7.11.tar.gz cmake-2.8.12.2-4.el6.x86_64.rpm


TAR-ZXF mysql-boost-5.7.11.tar.gz

RPM-IVH cmake-2.8.12.2-4.el6.x86_64.rpm #要求cmake版本2.8 and above

compiling MySQL

The relevant parameters are as follows:

cmake-dcmake_install_prefix=/usr/local/lnmp/mysql-dmysql_datadir=/usr/local/lnmp/mysql/data-dmysql_unix_addr=/ Usr/local/lnmp/mysql/data/mysql.sock-dwith_innobase_storage_engine=1-dwith_myisam_storage_engine=1-ddefault_ Charset=utf8-ddefault_collation=utf8_general_ci-dextra_charsets=all-ddownload_boost=1-dwith_boost=boost/boost_ 1_59_0/

PS:-dwith_boost=boost/boost_1_59_0/This parameter is the location of the decompression BOOST package, fill in according to the actual situation.


Do && make install #注意make的时候比较慢, require at least 2G of memory, or there will be an error after

PS: It is also possible to use MAKE-J4 if your computer core is four CPUs, but beware of errors.


To create a user:

Useradd-m-d/usr/local/lnmp/mysql/-s/sbin/nologin MySQL #为mysql创建用户

Edit the configuration file, with the command

cd/usr/local/lnmp/mysql/support-files/

[email protected] support-files]# CP mysql.server/etc/init.d/mysqld #将mysql命令加入到/ETC/INIT.D

[Email protected] support-files]# chmod +x/etc/init.d/mysqld #给mysqld执行权限

CP my-default.cnf/etc/my.cnf #用编译好的配置文件替换mysql原有的配置文件

cd/usr/local/lnmp/mysql/

Chown Mysql.mysql-r.

Mysqld--initialize--basedir=/usr/local/lnmp/mysql/--user=mysql--datadir=/usr/local/lnmp/mysql/data # Generate the data file for the database

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/80/38/wKiom1c7w0HwxoZHAAEhLEoHypo924.png "title=" 1.png " alt= "Wkiom1c7w0hwxozhaaehleohypo924.png"/>


Chown Root-r. #更改相关的文件用户与用户组

Chown Mysql-r data/#data目录 and the file users below


After you have changed the permissions are as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/80/35/wKioL1c7xF2QNV7UAAB6HH_kvUI886.png "title=" 2.png " alt= "Wkiol1c7xf2qnv7uaab6hh_kvui886.png"/>


[Email protected] mysql]# mysql_secure_installation #mysql保险配置向导

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/80/38/wKiom1c7w5HCXsWQAACGYqg8Xmo011.png "title=" 3.png " alt= "Wkiom1c7w5hcxswqaacgyqg8xmo011.png"/>


Compile environment variables:

Vim ~/.bash_profile

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/35/wKioL1c7xJjxQhb1AABDh_TwJLk109.png "title=" 4.png " alt= "Wkiol1c7xjjxqhb1aabdh_twjlk109.png"/>

SOURCE ~/.bash_profile

/etc/init.d/mysqld Start #启动数据库

The configuration is complete and the database can be entered correctly:

Mysql-uroot-p

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/35/wKioL1c7xLnD1Z4sAACUgxb83VI979.png "title=" 5.png " alt= "Wkiol1c7xlnd1z4saacugxb83vi979.png"/>


The above has completed the MySQL database source installation, then quickly use it!



For the use of several basic statements of the database:

Common MySQL Commands:

Login:
MySQL–u user name [–h host name or IP address]–p password

to change the root password:
Use MySQL
Update user Set Password=password (' New password ') whereuser= ' root ';
Flush privileges;

create a user and authorize:
Insert into Mysql.user (Host,user,password) VALUES ("localhost", "user name ", Password (" password "));
Flush privileges;
Grant all privileges ontable name. * To user name @localhost identified by ' password ';

To Delete a user:
Delete from Mysql.user Where user= 'username ' andhost= ' localhost ';
Flush privileges;

To Modify a user password:
Update Mysql.user set Password=password ('new password ') where user= "user name" and host= "localhost";

To Change the database:
Use database_name

To import a database file:
Source C:\Users\Administrator\Desktop\ database file. sql

View All tables:
Show Tables ;




This article is from the "ptallrights" blog, make sure to keep this source http://ptallrights.blog.51cto.com/11151122/1774591

Linux under source installation compile MySQL database

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.