Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install and compile mysql database with source code under Linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MySQL is an open source relational database management system (RDBMS). The MySQL database system uses the most commonly used database management language-structured query language (SQL) for database management.

Here are the specific steps for installing the mysql database source code:

Environment: redhat6.5

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

Cmake-2.8.12.2-4.el6.x86_64.rpm # requires cmake version 2.8or above

# mysql#

Download the installation package and extract 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 # requires cmake version 2.8or above

Compile 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/

The parameter PS:-DWITH_BOOST=boost/boost_1_59_0/ is the location of the unzipped boost package, which is filled in according to the actual situation.

Make & & make install # Note that make is slow and requires at least 2 gigabytes of memory, otherwise an error will fail later.

PS: you can also use make-J4 here if your computer has four CPU cores, but be careful of making mistakes.

Create a user:

Useradd-M-d / usr/local/lnmp/mysql/-s / sbin/nologin mysql # create users for mysql

Edit configuration files, and command

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

[root@desktop support-files] # cp mysql.server/etc/init.d/mysqld # add the mysql command to / etc/init.d

[root@desktop support-files] # chmod + x / etc/init.d/mysqld # give mysqld execution permission

Cp my-default.cnf / etc/my.cnf # replaces mysql's original configuration file with the compiled configuration file

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 of the database

Chown root-R. # change related file users and user groups

Chown mysql-R data/ # data directory and its file users

After the change, the permissions are as follows:

[root@desktop mysql] # mysql_secure_installation # mysql Insurance configuration Wizard

Compile environment variables:

Vim / .bash_profile

Source / .bash_profile

/ etc/init.d/mysqld start # start the database

After the configuration is completed, you can enter the database correctly:

Mysql-uroot-p

The above has completed the source code installation of the mysql database, and then hurry to use it!

Here is the use of several basic database statements:

Common mysql commands:

Log in:

Mysql-u username [- h hostname or IP address]-p password

Change the password for root:

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 on table name. * to username @ localhost identified by 'password'

Delete a user:

Delete FROM mysql.user Where User=' username 'andHost='localhost'

Flush privileges

Change the user's password:

Update mysql.user set password=password ('new password') where User= "username" and Host= "localhost"

Change the database:

Use database_name

Import the database file:

Source C:\ Users\ Administrator\ Desktop\ database file. Sql

View all tables:

Show tables

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report