日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

linux系统编译安装mysql_Linux下编译安装MySQL

發(fā)布時(shí)間:2025/3/20 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux系统编译安装mysql_Linux下编译安装MySQL 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

獲得以下所需的源代碼包,并存放在/usr/local/src

與mysql相關(guān):boost_1_59_0.tar.gz cmake-3.6.2.tar.gz mysql-5.7.16.tar.gz

安裝cmake前的依賴包的安裝:

檢查gcc-c++ 、ncurses-devel是否安裝,如果沒有安裝,先用yum進(jìn)行安裝

編譯安裝cmake工具

cd /usr/local/src

tar xf cmake-3.6.2.tar.gz

cd cmake-3.6.2

./bootstrap --prefix=/usr/local/cmake

make

make install? ? ? ? ? ? ?//如果前面沒有指定安裝目錄,則默認(rèn)安裝到/usr/local/bin/cmake

建立mysql組和 用戶,并將mysql用戶添加到mysql組

groupadd mysql

useradd -g mysql mysql

創(chuàng)建mysql數(shù)據(jù)文件存放的目錄

mkdir /mydata

chown mysql:mysql /mydata

chmod o= /mydata? ? ? ? ? ?//設(shè)置其他人沒有任何權(quán)限

編譯安裝mysql

cd /usr/local/src

tar xf mysql-5.7.16.tar.gz

cd mysql-5.7.16

/usr/local/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata -DWITH_BOOST=/usr/local/src -DSYSCONFDIR=/etc -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 -DMYSQL_MAINTAINER_MODE=0 -DWITH_SSL:STRING=bundled -DWITH_ZLIB:STRING=bundled

make && make install

更改mysql安裝目錄的屬主屬組并添加mysql環(huán)境變量

chown -R mysql:mysql /usr/local/mysql

vim /etc/profile.d/mysql.sh

文件內(nèi)容是: export PATH=$PATH:/usr/local/mysql/bin

執(zhí)行命令:bash //讓新的PATH變量生效

安裝時(shí)/usr/local/mysql目錄找不到怎么辦?

查找資料說需要單獨(dú)安裝Development?Libraries開發(fā)包

[root@centos6-y ~]#

sudo?rpm?-ivh?mysql-community-devel-5.7.13-1.el7.x86_64.rpm

[sudo]?password?for?home:

warning:?mysql-community-devel-5.7.13-1.el7.x86_64.rpm:?Header?V3?DSA/SHA1?Signature,?key?ID?5072e1f5:?NOKEY

error:?Failed?dependencies:

libmysqlclient.so.20()(64bit)?is?needed?by?mysql-community-devel-5.7.13-1.el7.x86_64

mysql-community-libs(x86-64)?>=?5.7.9?is?needed?by?mysql-community-devel-5.7.13-1.el7.x86_64

[ocsr90@localhost?temp]$?sudo?rpm?-ivh?mysql-community-devel-5.7.13-1.el7.x86_64.rpm?--nodeps?--noforce

rpm:?--noforce:?unknown?option

[ocsr90@localhost?temp]$?sudo?rpm?-ivh?mysql-community-devel-5.7.13-1.el7.x86_64.rpm?--nodeps?--force

warning:?mysql-community-devel-5.7.13-1.el7.x86_64.rpm:?Header?V3?DSA/SHA1?Signature,?key?ID?5072e1f5:?NOKEY

Preparing...??????????????????????????#################################?[100%]

Updating?/?installing...

1:mysql-community-devel-5.7.13-1.el#################################?[100%]

安裝完,目錄/usr/include/mysql存在了

加入服務(wù)列表并設(shè)置為開機(jī)自啟

cd /usr/local/mysql/support-files

cp mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig mysqld on

修改mysql的配置文件

cat /etc/my.cnf

[mysql]

socket=/tmp/mysql.sock

[mysqld]

datadir=/mydata

socket=/tmp/mysql.sock

user=mysql

symbolic-links=0

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/mydata/mysqld.pid

初始化mysql

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mydata

說明:

##“-–initialize”會(huì)生成一個(gè)隨機(jī)密碼(~/.mysql_secret),而”–initialize-insecure”不會(huì)生成密碼。

##user表示指定用戶 ##basedir表示mysql的安裝路徑,datadir表示數(shù)據(jù)庫(kù)文件存放路徑。

啟動(dòng)mysql服務(wù)

# service mysqld start

查看MySQL服務(wù)的進(jìn)程和端口

# ps -ef | grep mysqld

root 22306 1 0 12:51 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mydata --pid-file=/mydata/web1.deng.com.pid

mysql 22480 22306 12 12:51 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mydata --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/mydata/web1.deng.com.pid --socket=/tmp/mysql.sock

#netstat -an | grep :3306

tcp 0 0 :::3306 :::* LISTEN

初始化MySQL數(shù)據(jù)庫(kù)的root用戶密碼

# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y #需要修改密碼,所以輸入y

There are three levels of password validation policy:

LOW Length >= 8

MEDIUM Length >= 8, numeric, mixed case, and special characters

STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 #設(shè)置密碼復(fù)雜度為強(qiáng)

Please set the password for root here.

New password:

Re-enter new password: #輸入2次新密碼

Estimated strength of the password: 100

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y #刪除匿名用戶

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y #禁止root遠(yuǎn)程登錄

... skipping.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y #刪除測(cè)試數(shù)據(jù)庫(kù)

- Dropping test database...

Success.

- Removing privileges on test database...

Success.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y #重新加載權(quán)限表

Success.

All done!

將MySQL數(shù)據(jù)庫(kù)的動(dòng)態(tài)鏈接庫(kù)共享至系統(tǒng)鏈接庫(kù)

vim /etc/ld.so.conf.d/mysql.conf

文件內(nèi)容是:

/usr/local/mysql/lib

ldconfig -v?//讓系統(tǒng)重新讀取庫(kù)文件

測(cè)試登陸MySQL數(shù)據(jù)庫(kù)

# mysql -uroot -p

Enter password: #輸入剛才設(shè)置的新密碼

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.14 Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.00 sec)

mysql>exit

Bye

總結(jié)

以上是生活随笔為你收集整理的linux系统编译安装mysql_Linux下编译安装MySQL的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。