Mysql基础教程:源码安装

来源: 系统之家 2013/11/28 11:39

由于其体积小、速度快、总体成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。下面系统之家小编为大家转载一篇Mysql源码安装教程,需要的朋友可以参考一下!

安装环境:

操作系统:CentOS 6.2
数据库:MYSQL 5.5.23
虚拟机:VMWARE 8.0.2

Mysql源码安装步骤:

1.首先,我们需要下载 Mysql源码安装包
2.服务器环境的配置:

下载到服务器上后,会发现与之前版本的安装有所区别,之前是使用的./configure来配置的,但是本次下载的版本已经没有了,但是多了几个cmake文件,查看相关文档得知,已经取代了之前的configure检查安装。所以环境中需要安装cmake包,当然gcc等关键安装包是必须的。

本次下载的cmake版本是cmake-2.8.3.tar.gz。

cmake的安装:

#tar xvf cmake-2.8.3.tar.gz
#cd cmake-2.8.3
#./bootstrap
#gmake
#gmake instal
[page]
3.用户配置

#groupadd mysql
#useradd mysql -g mysql

4.mysql的安装(root下)

# tar xvf mysql-5.5.23.tar.gz
# cd mysql-5.5.23
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock

-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

过程如下:

-- MySQL 5.5.23
-- Packaging as: mysql-5.5.23-Linux-x86_64
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql/mysql-5.5.23
敲cmake命令时将上述命令弄成一行回车。

编译及安装等

# make
# make install
# cd support-files/
# cp my-large.cnf /etc/my.cnf
# cp mysql.server /etc/init.d/mysqld

初始化DB

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

最后结果如下:

Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!
[page]
5.配置my.cnf

修改/etc/my.cnf文件,新增如下内容:

#added by kenyon 20120418 about the log para
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock

# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock

log-bin=/usr/local/mysql/log/mysql-bin
# expire_logs_days = 30
# max_binlog_size = 500M
log=/usr/local/mysql/log/mysql.log
log-error=/usr/local/mysql/log/error.log
long_query_time=2
log-slow-queries=/usr/local/mysql/log/slowquery.log
# log-queries-not-using-indexes=/usr/local/mysql/log/nouseindex.log

[mysqld_safe]
datadir=/usr/local/mysql/data/

6.授权

# chown -R mysql /usr/local/mysql/data
# mkdir /usr/local/mysql/log
# chown -R mysql /usr/local/mysql/log

7.启动与关闭

启动:

/usr/local/mysql/bin/mysqld_safe &
[mysql@localhost log]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.23-log Source distribution

Copyright (c) 2000, 2011, 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> select version();
+------------+
| version() |
+------------+
| 5.5.23-log |
+------------+
1 row in set (0.00 sec)

在/etc/init.d/mysqld新增
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

完了,该文件除了启动和关闭也可以有其他用处

启动:/etc/init.d/mysqld start
关闭:/etc/init.d/mysqld stop
重载:/etc/init.d/mysqld reload/force-reload
状态:/etc/init.d/mysqld status

本文来自于【系统之家www.xp85.com

猜你喜欢

新闻资讯

装机必备

生活服务

现代都市人很多起床第一件事就是拿手机看最新的新闻资讯,看看今天最新的资讯内容,现在手机上各种新闻客户端有很多,如果今日头条,腾讯新闻,凤凰新闻,网易新闻等。

进入专区

安卓装机必备,一站式必装应用大全,为您精选好用的手机必装应用,自动为您推荐当下热门、好用的软件。安装精品应用更加方便快捷!

  • 必剪app 必剪
  • 饭团看书app 饭团看书
  • 饭团探书app 饭团探书
  • 卡通相机app 卡通相机
  • 盲盒大玩家app 盲盒大玩家
  • 多多计算器安卓版 多多计算器
  • 嘿市app 嘿市
  • 头像空间app 头像空间
进入专区

生活服务分类聚集的大量我们生活中平常用的软件,只要你想得到的基本通通有,欢迎使用!

  • 垃圾分类大师安卓版 垃圾分类大师
  • 标准商标查询安卓版 标准商标查询
  •  医学三基题库安卓版 医学三基题库
  • 天天看港剧安卓版 天天看港剧
  • 趣伴安卓版 趣伴
  • 日本换乘安卓版 日本换乘
  • 蘑菇影视安卓版 蘑菇影视
  • 影院通电影票安卓版 影院通电影票
进入专区

用户评论

全部
//wap教程