设为首页 收藏本站
查看: 406|回复: 0

[经验分享] MySQL安装

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-1-29 08:12:10 | 显示全部楼层 |阅读模式
MySQL安装
一、下载Mysql
http://mirrors.sohu.com/  ----搜狐开源镜像站
http://mirrors.163.com/   ----网易开源镜像站

[iyunv@localhost src]# pwd
/usr/local/src
[iyunv@localhost src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73.tar.gz
--2015-01-06 22:30:03--  http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73.tar.gz
Resolving mirrors.sohu.com... 119.188.36.70
Connecting to mirrors.sohu.com|119.188.36.70|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24023347 (23M) [application/octet-stream]
Saving to: “mysql-5.1.73.tar.gz”

100%[======================================>] 24,023,347   690K/s   in 56s     

2015-01-06 22:30:58 (422 KB/s) - “mysql-5.1.73.tar.gz” saved [24023347/24023347]
二、解刚才下载的Mysql
[iyunv@localhost src]# ll
total 23464
-rw-r--r--. 1 root root 24023347 Nov  5  2013 mysql-5.1.73.tar.gz
[iyunv@localhost src]# tar zxf mysql-5.1.73.tar.gz
三、创建Mysql用户和组
[iyunv@localhost src]# groupadd -g 400 mysql
[iyunv@localhost src]# useradd -M -u 400 -g 400 -s /sbin/nologin mysql
[iyunv@localhost src]# id mysql
uid=400(mysql) gid=400(mysql) groups=400(mysql)
四、编译安装MySQL
[iyunv@localhost src]# cd mysql-5.1.73
[iyunv@localhost mysql-5.1.73]# ./configure --prefix=/usr/local/mysql-5.1.73 --with-unix-socket-path=/usr/local/mysql-5.1.73/tmp/mysql.sock --localstatedir=/usr/local/mysql-5.1.73/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static  

./configure的最后提示信息,出现以下信息表示正确

Thank you for choosing MySQL!

Remember to check the platform specific part of the reference manual
for hints about installing MySQL on your platform.
Also have a look at the files in the Docs directory.



错误:checking for termcap functions library... configure: error: No curses/termcap library found
解决:[iyunv@localhost ~]# yum install -y ncurses-devel

[iyunv@localhost mysql-5.1.73]# make
make结束后的提示信息如下:
make[1]: Leaving directory `/usr/local/src/mysql-5.1.73/server-tools'
Making all in win
make[1]: Entering directory `/usr/local/src/mysql-5.1.73/win'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/local/src/mysql-5.1.73/win'

[iyunv@localhost mysql-5.1.73]# make install
make install结束后的提示信息如下:
make[2]: Leaving directory `/usr/local/src/mysql-5.1.73/win'
make[1]: Leaving directory `/usr/local/src/mysql-5.1.73/win'
五、拷贝配置文件及启动脚本
[iyunv@localhost mysql-5.1.73]# cp support-files/my-medium.cnf /etc/my.cnf
[iyunv@localhost mysql-5.1.73]# cp support-files/mysql.server /etc/init.d/mysqld
[iyunv@localhost mysql-5.1.73]# chmod 700 /etc/init.d/mysqld
[iyunv@localhost mysql-5.1.73]# chkconfig --add mysqld
[iyunv@localhost mysql-5.1.73]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
六、做符号链接,便于访问
[iyunv@localhost mysql-5.1.73]# ln -s /usr/local/mysql-5.1.73/ /usr/local/mysql
[iyunv@localhost mysql-5.1.73]# cd /usr/local/mysql
[iyunv@localhost mysql]# ll
total 28
drwxr-xr-x.  2 root root 4096 Jan  6 23:55 bin
drwxr-xr-x.  3 root root 4096 Jan  6 23:54 include
drwxr-xr-x.  3 root root 4096 Jan  6 23:54 lib
drwxr-xr-x.  2 root root 4096 Jan  7 00:08 libexec
drwxr-xr-x. 10 root root 4096 Jan  7 00:08 mysql-test
drwxr-xr-x.  6 root root 4096 Jan  7 00:08 share
drwxr-xr-x.  5 root root 4096 Jan  7 00:08 sql-bench
七、进行mysql初始化
[iyunv@localhost mysql]# ./bin/mysql_install_db --user=mysql
Installing MySQL system tables...
150107  0:15:52 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
150107  0:15:53 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
[iyunv@localhost mysql]# ll
total 32
drwxr-xr-x.  2 root  root 4096 Jan  6 23:55 bin
drwx------.  4 mysql root 4096 Jan  7 00:15 data
drwxr-xr-x.  3 root  root 4096 Jan  6 23:54 include
drwxr-xr-x.  3 root  root 4096 Jan  6 23:54 lib
drwxr-xr-x.  2 root  root 4096 Jan  7 00:08 libexec
drwxr-xr-x. 10 root  root 4096 Jan  7 00:08 mysql-test
drwxr-xr-x.  6 root  root 4096 Jan  7 00:08 share
drwxr-xr-x.  5 root  root 4096 Jan  7 00:08 sql-bench
八、设置目录属主
[iyunv@localhost mysql]# chown -R mysql.mysql /usr/local/mysql
九、以脚本方式进行启动
[iyunv@localhost mysql]# ./bin/mysqld_safe --user=mysql &
[1] 53830
[iyunv@localhost mysql]# 150107 00:18:37 mysqld_safe Logging to '/usr/local/mysql/data/localhost.err'.
150107 00:18:37 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
                                                                            ---回车
十、连接数据库
[iyunv@localhost mysql]# ./bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2013, 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              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql>
十一、优化mysql命令路径
[iyunv@localhost mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin/">>/etc/profile
[iyunv@localhost mysql]# source  /etc/profile



编译选项详解:
--prefix=/usr/local/mysql  ----------设定mysql安装路径
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock  ----设定mysql socket文件存放目录
--localstatedir=/usr/local/mysql/data   --设定mysql的数据文件存放位置
--enable-assembler    -----允许汇编模式(优化性能),使用一些字符函数的汇编版本
--with-mysqld-ldflag=-all-static    ---服务器使用静态库(优化性能),服务器端链接参数,本文示例为指定静态编译mysql服务器,(静态链接提高13%性能)
--with-client-ldflag=-all-static     ---客户端使用静态库(优化性能),客户端链接参数,本文示例为指定静态编译mysql客户端,(静态链接提高13%性能)
--enable-thread-safe-client       --以线程方式编译客户端
--with-mysqld-user=mysql        --指定mysql运行的系统用户
--with-big-tables                                  ----32位平台上支持大于4G行的表
--without-debug               ---使用非debug模式
--with-pthread                                      --强制使用pthread线程序库编译
--with-extra-charsets=complex       --服务器需要支持的字符集,有三种可能的值:空格间隔的一系列字符集名;complex ,包括不能动态装载的所有字符集;all,将所有字符集包括进二进制
-with-readline
--with-ssl              ----启用SSL支持
-with-embedded-server    ---编译embedded-server,构建嵌入式MySQL库
--enable-local-infile -----让mysql支持从本地文件导入数据库

--with-plugins=partition,innobase     ----MySQL服务器端支持的存储引擎组件(默认为空),可选值较多:

partition:MySQL Partitioning Support;

daemon_example:This is an example plugin daemon;

ftexample:Simple full-text parser plugin;

archive:Archive Storage Engine;

blackhole:Basic Write-only Read-never tables;

csv:Stores tables in text CSV format,强制安装;

example:Example for Storage Engines for developers;

federated:Connects to tables on remote MySQL servers;

heap:Volatile memory based tables,强制安装;

ibmdb2i:IBM DB2 for i Storage Engine;

innobase:Transactional Tables using InnoDB;

innodb_plugin:Transactional Tables using InnoDB;

myisam:Traditional non-transactional MySQL tables,强制安装;

myisammrg:Merge multiple MySQL tables into one,强制安装;

ndbcluster:High Availability Clustered tables;)



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-41619-1-1.html 上篇帖子: keepalived +mysql 构建MYSQL AAB架构 下篇帖子: Mysql数据库连接池知识分享
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表