已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Mysql 源码安装一、文章说明 最近接触到mysql数据库,因此闲来研究一下,今天演示一下用源码安装mysql,如果使用rpm包安装的话个人感觉挺简单的。 环境说明: 操作系统:rhel 5.4 x86 Mysql版本:mysql-5.5.22二、安装cmake(mysql5.5以后是通过cmake来编译的) 在mysql5.5之前的话直接编辑就可以,而在5.5以后需要通过cmake来编译,在附录中介绍一下直接编译。 下载cmake-2.8.4.tar.gz,本人是在度娘搜的。rootnode4 # tar -zxvf cmake-2.8.4.tar.gzrootnode4 # cd cmake-2.8.4rootnode4 cmake-2.8.4# ./configure -prefix=/usr/local/cmake-在这里可以使用# gmake & make installrootnode4 cmake-2.8.4# makerootnode4 cmake-2.8.4# make install 备注:configure需要执行编译到目录。三、创建mysql的安装目录及数据库存放目录rootnode4 # mkdir -p /opt/mysql5.5rootnode4 # mkdir -p /opt/mysql5.5/data 四、创建mysql用户及用户组rootnode4 # groupadd mysqlrootnode4 # useradd -r -g mysql mysql五、安装mysqlrootnode4 # tar -zxvf mysql-5.5.22.tar.gzrootnode4 # cd mysql-5.5.22-编译出现以下错误,需要ncurses-develrootnode4 mysql-5.5.22#/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql5.5 -DMYSQL_DATADIR=/opt/mysql5.5/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1- MySQL 5.5.22- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:83 (MESSAGE): Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.Call Stack (most recent call first): cmake/readline.cmake:127 (FIND_CURSES) cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT) CMakeLists.txt:268 (MYSQL_CHECK_READLINE)- Configuring incomplete, errors occurred!-查看ncurses是否安装:rootnode4 mysql-5.5.22# rpm -qa|grep necursesncurses-5.5-24.20060715-安装ncurses-develrootnode4# rpm -ivh ncurses-devel-5.5-24.20060715.i386.rpm warning: ncurses-devel-5.5-24.20060715.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing. # 100% 1:ncurses-devel # 100%-删除CMakeCache.txtrootnode4 mysql-5.5.22# find / -name CMakeCache.txt/root/mysql-5.5.22/CMakeCache.txt/root/cmake-2.8.4/CMakeCache.txt/root/cmake-2.8.4/Tests/ComplexOneConfig/Cache/CMakeCache.txt/root/cmake-2.8.4/Tests/Complex/Cache/CMakeCache.txt/root/cmake-2.8.4/Tests/CMakeFiles/CheckFortran/CMakeCache.txt/root/cmake-2.8.4/Tests/ComplexRelativePaths/Cache/CMakeCache.txtrootnode4 mysql-5.5.22# rm /root/mysql-5.5.22/CMakeCache.txtrm: remove regular file /root/mysql-5.5.22/CMakeCache.txt? yesrootnode4 mysql-5.5.22# rm /root/cmake-2.8.4/CMakeCache.txtrm: remove regular file /root/cmake-2.8.4/CMakeCache.txt? yesrootnode4 mysql-5.5.22# rm /root/cmake-2.8.4/Tests/ComplexOneConfig/Cache/CMakeCache.txtrm: remove regular file /root/cmake-2.8.4/Tests/ComplexOneConfig/Cache/CMakeCache.txt? yesrootnode4 mysql-5.5.22# rm /root/cmake-2.8.4/Tests/Complex/Cache/CMakeCache.txtrm: remove regular file /root/cmake-2.8.4/Tests/Complex/Cache/CMakeCache.txt? yesrootnode4 mysql-5.5.22# rm /root/cmake-2.8.4/Tests/CMakeFiles/CheckFortran/CMakeCache.txtrm: remove regular file /root/cmake-2.8.4/Tests/CMakeFiles/CheckFortran/CMakeCache.txt? yesrootnode4 mysql-5.5.22# rm /root/cmake-2.8.4/Tests/ComplexRelativePaths/Cache/CMakeCache.txtrm: remove regular file /root/cmake-2.8.4/Tests/ComplexRelativePaths/Cache/CMakeCache.txt? yes-再次进行编译:rootnode4 mysql-5.5.22#/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql5.5 -DMYSQL_DATADIR=/opt/mysql5.5/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1rootnode4 mysql-5.5.22#make & make install 备注:-DCMAKE_INSTALL_PREFIX=/usr/local/mysql /安装目录-DINSTALL_DATADIR=/usr/local/mysql/data /数据库存放目录-DDEFAULT_CHARSET=utf8 /使用utf8字符-DDEFAULT_COLLATION=utf8_general_ci /校验字符-DEXTRA_CHARSETS=all /安装所有扩展字符集-DENABLED_LOCAL_INFILE=1 /允许从本地导入数据 注意事项: 重新编译时,需要清除旧的对象文件和缓存信息。 #make clean #rm -f CMakeCache.txt #rm -rf /etc/f六、设置目录权限rootnode4 # cd /opt/mysql5.5/rootnode4 mysql5.5# chown -R root:mysql . /把当前目录中所有文件的所有者设为root,所属组为mysql rootnode4 mysql5.5# chown -R mysql:mysql data/七、设置mysql配置文件rootnode4 mysql5.5# cp support-files/f /etc/f /将mysql的启动服务添加到系统服务中rootnode4 mysql5.5# cp support-files/f frootnode4 mysql5.5# more f -在mysqld下面添加basedir = /opt/mysql5.5 datadir = /opt/mysql5.5/data mysqldport = 3306socket = /tmp/mysql.sockskip-external-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8Mbasedir = /opt/mysql5.5datadir = /opt/mysql5.5/data八、创建系统数据库的表-在这里指定了配置文件和用户 rootnode4 mysql5.5# cd /mysql5.5rootnode4 mysql5.5# scripts/mysql_install_db -defaults-file=./f -user=mysql Installing MySQL system tables.OKFilling help tables.OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/opt/mysql5.5/bin/mysqladmin -u root password new-password/opt/mysql5.5/bin/mysqladmin -u root -h node4 password new-passwordAlternatively you can run:/opt/mysql5.5/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /opt/mysql5.5 ; /opt/mysql5.5/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /opt/mysql5.5/mysql-test ; perl mysql-test-run.plPlease report any problems with the /opt/mysql5.5/scripts/mysqlbug script!九、设置环境变量rootnode4 # vi /root/.bash_profile -在PATH=$PATH:$HOME/bin添加参数为:PATH=$PATH:$HOME/bin:/opt/mysql5.5/bin:/opt/mysql5.5/librootnode4 # source /root/.bash_profile 十、手动启动mysqlrootnode4 mysql5.5# ./bin/mysqld_safe -user=mysql & /启动MySql但不能停止1 27412rootnode4 mysql5.5# 130728 08:34:38 mysqld_safe Logging to /opt/mysql5.5/data/node4.err.130728 08:34:38 mysqld_safe Starting mysqld daemon with databases from /opt/mysql5.5/data-这里MYSQL的root用户还没有配置密码,所以空值。需要输入密码时,直接点回车键即可。 rootnode4 mysql5.5# ./bin/mysqladmin -u root -p shutdownEnter password: 130728 08:34:46 mysqld_safe mysqld from pid file /opt/mysql5.5/data/node4.pid ended1+ Done ./bin/mysqld_safe -user=mysql十一、另一个简单的启动mysql的方法(mysql已经被添加到系统服务中)rootnode4 mysql5.5# service mysql startrootnode4 mysql5.5# service mysql stoprootnode4 mysql5.5# service mysql restart 如果上述命令出现:mysql未识别的服务rootnode4 mysql5.5# service mysql startmysql.server: unrecognized service 则可能mysql还没添加到系统服务中,下面用另一个方法添加:rootnode4 mysql5.5# cp support-files/mysql.server /etc/init.d/mysqlrootnode4 mysql5.5# service mysql startStarting MySQL. OK rootnode4 mysql5.5# service mysql stopShutting down MySQL. OK 注意:主要是将mysql.server拷贝到/etc/init.d中,命名为mysql。然后再用#service mysql start 来启动mysql即可。十二、修改Mysql的root用户密码以及打开远程连接rootnode4 # /opt/mysql5.5/bin/mysql -u root mysqlWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 1Server version: 5.5.22-log Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type help; or h for help. Type c to clear the current input statement.mysql use mysql;Database changedmysql desc user;-为root添加远程连接的能力。mysql grant all privileges on *.* to root% identified by root;Query OK, 0 rows affected (0.03 sec)mysql update user set Password = password(123456) where User=root;Query OK, 5 rows affected (0.02 sec)Rows matched: 5 Changed: 5 Warnings: 0mysql select Host,User,Password from user where User=root;+-+-+-+| Host | User | Password |+-+-+-+| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | node4 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | :1 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |+-+-+-+5 rows in set (0.00 sec)mysql flush privileges;Query OK, 0 rows affected (0.01 sec)mysql exit;Byerootnode4 # /opt/mysql5.5/bin/mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 3Server version: 5.5.22-log Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type help; or h for help. Type c to clear the
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 透析溶血应急预案
- 油漆储存与运输安全规范
- 物流公司员工宿舍管理规定
- 办公空间智能化改造合同样本
- 生产线设备缺陷管理规范
- 电力行业合同管理准则
- 城市公交安全守则
- 邮政快递员聘用合同范本
- 芜湖保龄球馆租赁合同
- 山东教育设施建设合同
- 期中测试卷(试题)2024-2025学年人教版数学三年级上册
- 车队车辆挂靠合同模板
- 期中 (试题) -2024-2025学年人教PEP版英语四年级上册
- 动物疫病防治员(高级)理论考试题及答案
- 跨境电商行业研究框架专题报告
- 2024-2030年中国移动云行业市场发展趋势与前景展望战略研究报告
- 提升初中生英语写作
- 2024年深圳市优才人力资源有限公司招考聘用综合网格员(派遣至吉华街道)高频500题难、易错点模拟试题附带答案详解
- 高中政治必修四哲学与文化知识点总结
- 湖北省襄阳市2023-2024学年六年级上学期语文期中考试试卷(含答案)
- 医学课件血管性痴呆
评论
0/150
提交评论