Mysql 不同版本市场占有比例
mysql 5.1 20%
mysql 5.5 60%
mysql5.6 20%
一般公司用的是社区版:
MySQL Community Edition(GPL)
Community (GPL) Downloads »
下载链接:https://dev.mysql.com/downloads/mysql/
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd mysql -g mysql -M -s /sbin/nologin
[root@localhost ~]# cd /home/oldboy/tools/
[root@localhost tools]# tar xf mysql-5.1.72.tar.gz
[root@localhost tools]# cd mysql-5.1.72
[root@localhost mysql-5.1.72]# yum install ncurses-devel gcc
[root@localhost mysql-5.1.72]# pwd
/home/oldboy/tools/mysql-5.1.72
[root@localhost mysql-5.1.72]# cat log.sh
./configure \
--prefix=/application/mysql5.1.72 \
--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \
--localstatedir=/application/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--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
[root@localhost mysql-5.1.72]# cat log.sh |bash
config.status: creating include/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
/usr/bin/rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
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.
[root@localhost mysql-5.1.72]# echo $?
0
[root@localhost mysql-5.1.72]# make && make install
[root@localhost mysql-5.1.72]# ln -s /application/ mysql-5.1.72 / /application/mysql
如果mysql和web服务器不在同一台机器,到上面步骤,安装完毕数据库!!
如果在同一台机器上,就接着执行如下步骤。
[root@localhost support-files]# pwd
/home/oldboy/tools/mysql-5.1.72/support-files
[root@localhost support-files]#
[root@moban support-files]# ll my-*.cnf
-rw-r--r--. 1 root root 4746 May 25 22:59 my-huge.cnf
-rw-r--r--. 1 root root 19779 May 25 22:59 my-innodb-heavy-4G.cnf
-rw-r--r--. 1 root root 4720 May 25 22:59 my-large.cnf
-rw-r--r--. 1 root root 4731 May 25 22:59 my-medium.cnf
-rw-r--r--. 1 root root 2499 May 25 22:59 my-small.cnf
[root@localhost support-files]# cp my-small.cnf /etc/my.cnf (初始化数据库配置文件)
创建mysql数据文件目录
[root@localhost support-files]# mkdir /application/mysql/data -p
[root@localhost support-files]# chown -R mysql.mysql /application/mysql/
数据库初始化
[root@localhost support-files]# /application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# chkconfig --add mysqld
[root@localhost support-files]# chkconfig mysqld on
[root@localhost support-files]# chmod +x /etc/init.d/mysqld
[root@localhost support-files]# /etc/init.d/mysqld start
[root@localhost support-files]#
到此就安装完成了。
接下来就是登陆mysql了。一开始是没有密码的,直接就可以登陆。
[root@httpd support-files]# mysql //直接登录(可能出现问题)
必须将mysql 加到系统环境变量才能知道MySQL是哪个。
[root@localhost support-files]# vim /etc/profile
[root@localhost support-files]# grep mysql /etc/profile
PATH="/application/mysql/bin/:$PATH"
[root@localhost support-files]# ./etc/profile //让它生效
[root@localhost support-files]#mysql -uroot -p //就可以登录了
[root@localhost support-files]#
刚刚创建root还没有密码,可以为他创建个密码:
/application/mysql/bin/mysqladmin -u root -h moban password 'new-password'
第一种方法:(是哪种启动就用哪种关闭)
启动:
/application/mysql/bin/mysqld_safe &
关闭:
mysqladmin shutdown
第二种方法:(混合用有问题)
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
注意:安装过程出现这个报错:
[root@moban support-files]# /etc/init.d/mysqld start
Starting MySQL. ERROR! Manager of pid-file quit without updating file.
[root@moban support-files]# /application/mysql/bin/mysqld_safe &
[1] 46355
[root@moban support-files]# 180526 00:19:21 mysqld_safe Logging to '/var/log/mysqld.log'.
180526 00:19:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
180526 00:19:21 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
解决方法:再次执行
[root@localhost support-files]# /application/mysql/bin/mysql_install_db
[root@moban bin]# ps -ef|grep mysql
root 75378 1 0 10:47 pts/0 00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/moban.pid
mysql 75467 75378 0 10:47 pts/0 00:00:00 /application/mysql/libexec/mysqld --basedir=/application/mysql --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/lib/mysql/moban.pid --socket=/var/lib/mysql/mysql.sock
root 101511 1926 0 11:27 pts/0 00:00:00 grep mysql
[root@moban bin]#
[root@moban bin]# find / -name "mysql.sock"
/var/lib/mysql/mysql.sock
[root@moban bin]# /application/mysql/bin/mysql -u root -p -S /var/lib/mysql/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.72 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>