mysql数据库的安装之一源码安装

甲骨文关系型数据库管理系统

mysql数据库安装方式有多种,本文介绍源码安装

系统环境:

Linux mysql 2.6.32-642.6.1.el6。x86_64 # 1 SMP结婚2016年10月5日00:36:12 UTC x86_64 x86_64 x86_64 GNU/Linux

[root@mysql ~] #猫/etc/redhat-release 

CentOS 6.8版本(最终)

<李>

创建用户和组

useradd groupadd mysql mysql mysql - g - m - s/sbin/nologin

[root@mysql ~] # id mysql

uid=502 (mysql) gid=502 (mysql)组=502 (mysql)

2。解压源码并编译安装

tar xf mysql-5.1.72.tar。广州cd mysql-5.1.72

#编译

。/配置\

——prefix=/应用程序/mysql5.1.72 \

——with-unix-socket-path=/应用程序/mysql5.1.72/tmp/mysql。袜子\

——localstatedir=/应用程序/mysql5.1.72/数据\

——enable-assembler \

——enable-thread-safe-client \

——with-mysqld-user=mysql \

——with-big-tables \

——without-debug \

——with-pthread \

——enable-assembler \

——with-extra-charsets=复杂\

——with-readline \

——使用ssl \

——with-embedded-server \

——enable-local-infile \

——使用插件=分区,innobase \

——with-mysqld-ldflags=所有静态\

——with-client-ldflags=-all-static 


做,,使安装

3。做软链接

ln - s/应用程序/mysql5.1.72//应用程序/mysql

我/应用程序/mysql

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

重要:如果mysql不是和apache部署在同一台电脑上,到此结束。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

4。数据库的初始化

cd/工具/mysql-5.1.72

, ls支持文件/我* .cnf,,,,,#显示mysql配置文件cd支持文件

cp my-small.cnf/etc/my.cnf,,,,#复制配置文件


mkdir - p/应用程序/mysql/数据,,#建立mysql数据文件存放目录


乔恩- r mysql: mysql/应用程序/mysql, #授权mysql用户能访问mysql的安装目录


我/应用程序/mysql/数据


/应用程序/mysql/bin/mysql_install_db basedir=/应用程序/mysql——datadir=/应用程序/mysql/数据——用户=mysql

#出现2个好的,表示成功


我/应用程序/mysql/数据


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

vim/etc/init.d/mysqld

basedir=/应用程序/mysql,,,,,,,,,,,,,


datadir=/应用程序/mysql/数据,,,,,,,,,,

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

5。复制启动文件

cd/工具/mysql-5.1.72/支持文件

cp mysql。服务器/etc/init。d/mysqld


6。加入开机自启动

chkconfig mysqld

root@mysql ~ #。/etc/profile,#使之生效


#设置密码,不要在mysql>,下面设置密码,在#后面设置密码

/应用程序/mysql/bin/mysqladmin - u,根密码“passwd123”

#重新登录,输入用户名和密码


mysql - u root - p

passwd123


7。数据优化:

选择版本();,,,,#查看数据库版本

选择用户();,,,,,,#查看当前的用户

mysql>显示数据库;,,#查看数据库

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

|数据库,,,,,|

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

| information_schema |

| mysql,,,,,,,|

|测试,,,,,,,|

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


mysql>减少数据库测试;#安全设置,删除没有用的数据库

最终优化为:

mysql>显示数据库;

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

|数据库,,,,,|

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

| information_schema |

| mysql,,,,,,,|

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

mysql>选择用户,从mysql.user主机;,#查询表中的用户

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

| |用户主机,,,|

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

| |根127.0.0.1 |

|,,localhost, | |

| |根localhost |

|,,,| weblamp,|

| |根weblamp,|

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

删除用户”“@weblamp;,#删除主机名是weblamp,用户名="。

mysql>降低用户”“@localhost;

mysql数据库的安装之一源码安装