1、源码安装MySQL 5.1 GA创建组和用户: [root@mysqldb2 ~]# groupadd mysql
解压缩安装包: [root@mysqldb2 ~]$ cd /data/software/ [root@mysqldb2 software]$ tar xvfz mysql-5.1.51.tar.gz
进入mysql安装包目录,执行configure并加载适当参数:
提示:configure支持的选项非常多,详细的参数及说明建议参考官方文档,也可以通过./configure --help查看,这里仅列出常用及推荐使用的选项。
提示:执行Configure时如果报bin/rm: cannot remove `libtoolt¨: No such file or directory错误,可按照下列步骤解决: 1、确认libtool是否已经安装,如果没有安装的话,则先安装libtool # rpm -qa | grep libtool # yum -y install libtool 2、分别执行以下三条命令: # autoreconf --force --install # libtoolize --automake --force # automake --force --add-missing
继续执行编译: [root@mysqldb2 mysql-5.1.51]# make > /home/jss/mysql_setuplogs_make.log 2>&1
修改相关路径权限: [root@mysqldb2 mysql-5.1.51]# cd /usr/local/
复制程序文件到/usr/bin目录下,方便调用:
至此,MySQL数据库软件安装完成,此时已可使用mysql命令行工具连接其它MySQL数据库服务器了。
2. 创建数据库
创建目录并修改权限: [root@mysqldb2 local]# cd /data [root@mysqldb2 data]# mkdir mysqldata [root@mysqldb2 data]# cd mysqldata [root@mysqldb2 mysqldata]# mkdir 3306 [root@mysqldb2 mysqldata]# cd 3306 [root@mysqldb2 3306]# mkdir data binlog tmp innodb_ts innodb_log [root@mysqldb2 3306]# cd /data
创建数据库: [root@mysqldb2 local]# cd mysql/ [root@mysqldb2 mysql]# bin/mysql_install_db --user=mysql --datadir=/data/mysqldata/3306/data 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 mysqldb2 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
编辑和修改my.cnf配置文件,下列内容仅供参考: [root@mysqldb2 mysql]# vi /data/mysqldata/3306/my.cnf
[client] # Here follows entries for some specific programs
# The MySQL server
max_connections = 1000 default-storage-engine = InnoDB
net_buffer_length = 8K
query_cache_size = 128M
thread_cache_size = 300
#*********** Logs related settings ***********
#*********** MyISAM Specific options ***********
#*********** INNODB Specific options ***********
innodb_additional_mem_pool_size = 16M
innodb_file_io_threads = 4
innodb_log_group_home_dir = /data/mysqldata/3306/innodb_log
[mysqldump]
[mysql]
[myisamchk]
[mysqlhotcopy]
[mysqld_safe] 启动数据库:
设置超级用户密码:
可以通过netstat或ps等命令查看mysqld是否正常加载,由于默认指定mysqld端口号为3306,因此通过netstat查看是否存在3306端口即可,例如: [root@mysqldb2 mysql]# netstat -lnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:864 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:11111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:16851 0.0.0.0:* LISTEN
3. 创建第2个数据库
源码安装最大的优点就是灵活(缺点当然也很明显:复杂),不过能够创建一个数据库出来,再创建第二个自然也不在话下,事实上创建第2个数据库与第1个从步骤上看,基本也没什么区别,只要注意修改相关路径,和mysql运行的端口号即可。 创建目录并修改权限: [root@mysqldb2 mysql]# mkdir /data/mysqldata/3307 [root@mysqldb2 mysql]# cd /data/mysqldata/3307/ [root@mysqldb2 3307]# mkdir data binlog tmp innodb_ts innodb_log [root@mysqldb2 3307]# cd /data/mysqldata
复制初始化参数文件:
修改初始化参数值,主要为路径和端口:
命令符下输入:
替换文件中所有3306为3307 编辑server-id的值,指定一个与3306数据库不同的值,比如说303307:
创建数据库: [root@mysqldb2 3307]# mysql_install_db --user=mysql --datadir=/data/mysqldata/3307/data Installing MySQL system tables... OK Filling help tables... OK ..........
启动数据库:
设置超级用户密码:
随后,就可以通过mysql登录了: [root@mysqldb2 3307]# mysql -uroot -p¨verysafe¨ -S /data/mysqldata/3307/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.51-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license
Type ¨help;¨ or ¨\h¨ for help. Type ¨\c¨ to clear the current input statement.
通过这种方式,还可以非常轻松的创建第三、四....或更多数据库。当然了,如果是要同时创建多个新库的话,也许接下来用cp的方式会更快捷一些,不过这就跟mysql_install_db没什么关系了~~~ |
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
北京夜场模特领队