-----------MySQL 5.0以后版本的安装-----------

MySQL安装

安装包学习的必杀绝技——就是阅读包的安装说明(readme & install)文档。

----------

# rm /etc/my.cnf            (安装前执行一下)

----------

1.Mysql-5.0.40.tar.gz

1.1.Source Installation Overview(lines 74 of install-source)

系统默认可能会安装三个mysql的包:

mysql-libs

mysql

mysql-devel

从下往上依赖关系。

源码包安装mysql检查环境

Shell> rpm -aq | grep mysql

Shell> rpm -ql mysql

Shell> rpm -qf /etc/my.conf

Shell> rpm -qc mysql-libs

Shell> rpm -qR mysql-libs

Shell> rpm -qd mysql

Shell> rpm -qi mysql

Shell> netstat -nlt

Shell> find / -name mysql

Shell> find / -name my.conf

Shell> cat /etc/passwd | grep mysql

Shell> cat /etc/group |

Shell> rpm -qa | grep gcc

Shell> rpm -qa | grep make

Shell> ls /home

添加用户

Shell> groupadd -r mysql

Shell> useradd -g mysql -M -r -s /sbin/nologin mysql

开始安装

Shell> vi INSTALL-SOURCE

Shell> ./configure --prefix=/usr/local/mysql

Shell> echo $?

Shell> make

Shell> echo $?

Shell> make install

Shell> echo $?

配置文件

Shell> cp support-files/my-medium.cnf /etc/my.conf

目录权限

Shell> cd /usr/local/mysql

Shell> chown -R mysql .

Shell> chgrp -R mysql .

初始化数据库

Shell> bin/mysql_install_db --user=mysql

开机启动

Shell> cp /support-files/mysql.server /etc/init.d/mysqld

Shell> chmod 755 /etc/init.d/mysqld

安全启动服务/把数据库的数据文件定义到其他磁盘设备上

Shell> bin/mysqld_safe --user=mysql --datadir=/dell/mysql_data

1.2.Typical‘configure’Options(lines 265 of  install-source)

配置Shell> ./configure --help

Shell> ./configure -h

仅仅编译客户端程序

Shell> ./configure --without-server

默认安装的目录/usr/local(数据目录/usr/local/var)。可以改写为:

Shell> ./configure --prefix=/usr/local/mysql

Shell> ./configure --prefix=/usr/local/ --localstatedir=/usr/local/mysql/data

使用unix的套接字方式连接数据库:

Shell> ./configure --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock

有gcc,没有c++库,可以使用gcc来作为c++的编译器:

Shell> CC=gcc CXX=gcc ./configure

Shell> ./configure --with-charset=gb2312

Shell> ./configure --with-charset=utf8

Shell> ./configure --with-charset=latin1(这个是默认值)

Shell> ./configure --with-collation=latin1_swedish_ci(这个是排序方法的默认值)

Shell> ./configure --with-extra-charsets=(空格分开)

Shell> ./configure --with-extra-charsets=all

重新编译一个源码树时:

Shell> rm config.cache

Shell> make clean

Shell> make dist

_____________

Mysql-5.1.72.tar.gz

安装方法跟上边的大同小异。

_____________

2.Mysql-5.5.22.tar.gz

2.1.Installing MySQL from Generic Binaries on Unix/Linux

系统默认可能会安装三个mysql的包:

mysql-libs

mysql

mysql-devel

从下往上依赖关系。

二进制文件安装mysql检查环境

Shell> rpm -aq | grep mysql

Shell> rpm -ql mysql

Shell> rpm -qf /etc/my.conf

Shell> rpm -qc mysql-libs

Shell> rpm -qR mysql-libs

Shell> rpm -qd mysql

Shell> rpm -qi mysql

Shell> netstat -nlt

Shell> find / -name mysql

Shell> find / -name my.conf

Shell> cat /etc/passwd | grep mysql

Shell> cat /etc/group |

Shell> rpm -qa | grep gcc

Shell> rpm -qa | grep make

Shell> ls /home

添加用户

Shell> groupadd mysql

Shell> useradd -r -g mysql -M -s /sbin/nologin mysql

开始安装

Shell> cd /usr/local

Shell> tar -zxvf ……

Shell> cd mysql

Shell> chown -R mysql .

Shell> chgrp -R mysql .

初始化数据库

Shell> scripts/mysql_install_db --user=mysql

Shell> chown -R root .

Shell> chown -R mysql data

配置操作

Shell> cp support-files/my-medium.cnf  /etc/my.cnf

Shell> cp support-files/mysql.server  /etc/init.d/mysqld

Shell> chmod 755 /etc/init.d/mysqld

启动服务

Shell> bin/mysqld_safe --user=mysql --datadir=/dell/mysql_data

2.2.Installing MySQL from Source

源码包安装mysql检查环境

Shell> rpm -aq | grep mysql

Shell> rpm -ql mysql

Shell> rpm -qf /etc/my.conf

Shell> rpm -qc mysql-libs

Shell> rpm -qR mysql-libs

Shell> rpm -qd mysql

Shell> rpm -qi mysql

Shell> netstat -nlt

Shell> find / -name mysql

Shell> find / -name my.conf

Shell> cat /etc/passwd | grep mysql

Shell> cat /etc/group |

Shell> rpm -qa | grep gcc

Shell> rpm -qa | grep make

Shell> ls /home

添加用户

Shell> groupadd mysql

Shell> useradd -r -g mysql -M -s /sbin/nologin mysql

配置、编译

Shell> ccmake .(先进行交互式配置)

Shell> cmake .

Shell> make

Shell> make install

Shell> cd /usr/local/mysql

Shell> chown -R mysql .

Shell> chgrp -R mysql .

初始化数据库

Shell> scripts/mysql_install_db --user=mysql

Shell> chown -R root .

Shell> chown -R mysql data

Shell> cp support-files/my-medium.cnf  /etc/my.cnf

Shell> cp support-files/mysql.server  /etc/init.d/mysqld

Shell> chmod 755 /etc/rc.d/init.d/mysqld

启动服务

Shell> bin/mysqld_safe --user=mysql --datadir=/dell/mysql_data

2.3.To list the configuration options,use one of the following.

Shell> cmake . -L# overview

Shell> cmake . -LH# overview with help text

Shell> cmake . -LAH# all params with help text

Shell> ccmake .# interactive display

Shell> make clean

Shell> rm CMakeCache.txt

2.4.rpmTo see all files in an RPM packet,run a command like this:

Shell> rpm -qpl MySQL-server-VERSION.glibc23.i386.rpm

Shell> rpm -ivh MySQL-server-VERSION.glibc23.i386.rpm

Shell> rpm -ivh MySQL-client-VERSION.glibc23.i386.rpm

Start from a source RPM,run:

Shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm

2.5.安装Cmake-2.8.12.tar.gzShell> vi Readme.txt

Shell> ./bootstrap

Shell> make

Shell> make install

3.Mysql-5.5.34.tar.gz

3.1. Installing MySQL on Unix/Linux Using Generic Binaries

二进制包安装mysql检查当前环境配置

Shell> rpm -aq | grep mysql

Shell> rpm -ql mysql

Shell> rpm -qf /etc/my.conf

Shell> rpm -qc mysql-libs

Shell> rpm -qR mysql-libs

Shell> rpm -qd mysql

Shell> rpm -qi mysql

Shell> netstat -nlt

Shell> find / -name mysql

Shell> find / -name my.conf

Shell> cat /etc/passwd | grep mysql

Shell> cat /etc/group |

Shell> rpm -qa | grep gcc

Shell> rpm -qa | grep make

添加用户

Shell> groupadd mysql

Shell> useradd -r -g mysql -M -s /sbin/nologin mysql

Shell> cd /usr/local

开始安装

Shell> tar -zxvf ……

Shell> cd mysql

设定目录权限

Shell> chown -R mysql .

Shell> chgrp -R mysql .

初始化数据库

Shell> scripts/mysql_install_db --user=mysql

设定库文件目录权限

Shell> chown -R root .

Shell> chown -R mysql data

添加配置文件

Shell> cp support-files/my-medium.cnf /etc/my.cnf

Shell> cp support-files/mysql.server /etc/init.d/mysqld

Shell> chmod 755 /etc/init.d/mysqld

启动服务

Shell> bin/mysqld_safe --user=mysql --datadir=/dell/mysql_data

3.2.Installing MySQL Using a Standard Source Distribution

源码包安装mysqlShell> rpm -aq | grep mysql

Shell> rpm -ql mysql

Shell> rpm -qf /etc/my.conf

Shell> rpm -qc mysql-libs

Shell> rpm -qR mysql-libs

Shell> rpm -qd mysql

Shell> rpm -qi mysql

Shell> netstat -nlt

Shell> find / -name mysql

Shell> find / -name my.conf

Shell> cat /etc/passwd | grep mysql

Shell> cat /etc/group |

Shell> rpm -qa | grep gcc

Shell> rpm -qa | grep make

Shell> ls /home

Shell> groupadd mysql

Shell> useradd -r -g mysql -M -s /sbin/nologin mysql

Shell> cd mysql

Shell> ccmake .(没有这一步也过去了)

Shell> cmake .

Shell> make

Shell> make install

Shell> cd /usr/local/mysql

Shell> chown -R mysql .

Shell> chgrp -R mysql .

Shell> scripts/mysql_install_db --user=mysql

Shell> chown -R root .

Shell> chown -R mysql data

Shell> cp support-files/my-medium.cnf /etc/my.cnf

Shell> cp support-files/mysql.server /etc/init.d/mysqld

Shell> chmod 755 /etc/init.d/mysqld

Shell> bin/mysqld_safe --user=mysql --datadir=/dell/mysql_data

4.Mysql-5.6.36.tar.gz

二进制包安装mysql添加用户

[root@tri blog]# groupadd -g 51 mysql

[root@tri blog]# useradd -r -u 51 -g 51 -d /data02/blog/mysql_data -s /sbin/nologin mysql

开始安装

[root@tri local]# tar -xf /opt/data01/tars/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

[root@tri local]# ln -s mysql-5.6.36-linux-glibc2.5-x86_64/ mysql

[root@tri local]# cd mysql

[root@tri mysql]# chown -R mysql:mysql .

[root@tri mysql]# scripts/mysql_install_db --user=mysql

[root@tri mysql]# chown -R root .

[root@tri mysql]# chown -R mysql data/

标准启动

[root@tri mysql]# bin/mysqld_safe --user=mysql

直接启动

[root@tri mysql]# bin/mysqld_safe --user=mysql --bind-address=127.0.0.1 --port 3333

解包后查看文件,编译时配置“-prefix=”

[root@tri mysql]# vi docs/INFO_BIN

CMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql

MYSQL_DATADIR:PATH=/usr/local/mysql/data

添加启动时打开服务

[root@tri mysql]# cp support-files/mysql.server /etc/init.d/mysql

打开上述文件(提示配置文件、主目录、数据目录)

[root@tri mysql]# vi /etc/init.d/mysql

# If you install MySQL on some other places than /usr/local/mysql, then you

# have to do one of the following things for this script to work:

#

# - Run this script from within the MySQL installation directory

# - Create a /etc/my.cnf file with the following information:

#   [mysqld]

#   basedir=

# - Add the above to any other configuration file (for example ~/.my.ini)

#   and copy my_print_defaults to /usr/bin

# - Add the path to the mysql-installation-directory to the basedir variable

#   below.

#

# If you want to affect other MySQL variables, you should make your changes

# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get

# overwritten by settings in the MySQL configuration files.

basedir=

datadir=

附:1.账号安全

-----------MySQL 安装完成后的帐号安全问题-----------

问题描述

刚安装好的系统, root 默认密码为空;默认空用户(空密码)也可以在本地登录;

查看系统中有那些账户:无用户名、密码本地登录

[work@tri ~]$ mysql

使用有用户名的方式登录

[work@tri ~]$ mysql -u root -h localhost

mysql> select host,user,password from mysql.user;

mysql> select host,user,password from mysql.user;

+-----------+------+----------+

| host      | user | password |

+-----------+------+----------+

| localhost | root |          |

| tri       | root |          |

| 127.0.0.1 | root |          |

| ::1       | root |          |

| localhost |      |          |

| tri       |      |          |

+-----------+------+----------+

6 rows in set (0.00 sec)

显示结果,表示有多个 root 用户;有两个 空用户。没有一个有密码。

这就需要为每一个用户设定密码;同样需要为空用户设定密码,或者删除。

mysql.db 中的某些行,允许所有用户(包括没有密码的空账户;anonymous)访问测试数据库或者其

他以 “test_” 开头的数据库。(这个默认设置是为了测试的)

-------

修改 root 密码shell> mysql -u root

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');

mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');

mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

mysql> select host,user,password from mysql.user;

shell> mysql -u root

mysql> UPDATE mysql.user SET password = PASSWORD('newpwd)

-> WHERE user = 'root';

(没有这步,就得重启后才能生效)

mysql> FLUSH PRIVILEGES;

shell> mysqladmin -u root password "newpwd"

shell> mysqladmin -u root -h host_name password "newpwd"

mysqladmin 无法对127.0.0.1起作用。

shell> mysqladmin -u root -p shutdown

-------修改 anonymous 密码

shell> mysql -u root -p

mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');

mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');

shell> mysql -u root -p

mysql> UPDATE mysql.user SET password = PASSWORD('newpwd')

-> WHERE user = '';

mysql> FLUSH PRIVILEGES;

-------删除 anonymous 用户

shell> mysql -u root -p

mysql> DROP USER ''@'localhost';

mysql> DROP USER ''@'host_name';

mysql> select host,user,password from mysql.user;

-------

拒绝任意用户访问测试数据库shell> mysql -u root -p

mysql> DELETE FROM mysql.db WHERE db LIKE 'test%';

mysql> FLUSH PRIVILEGES;

mysql> DROP DATABASE test;    (* 再进一步,连测试库都干掉)

-----------------------------

使用 RPM 包安装数据库

RPM 包可以是官方提供的,也可以是其他作者提供的;可能有所不同(文件结构)。

标准安装,需要 MySQL-server & MySQL-client 。(其他的包在标准安装中不需要)

4109 行有关于各种包(名称)代表含义的详细说明。(包对 CPU 是有选择的 4208 )

查看 RPM 包里的文件:shell> rpm -qpl MySQL-server-VERSION.glibc23.i386.rpm

-------

* Red Hat Linux, Fedora, CentOSroot-shell> yum install mysql mysql-server mysql-libs

root-shell> service mysqld start

root-shell> chkconfig --levels 235 mysqld on

-------

Debian,Ubuntu,Kubunturoot-shell> apt-get install mysql-client-5.1 mysql-server-5.1

root-shell> service mysql start | stop

-----------------------------

优化从编译个出色的mysqld开始使用最好的编译器、和最佳的编译选项;使用静态模板编译。这个很重要,性能能提升10-30%。

直接在官网下载的二进制包,包含所有的字符集;自己编译可以选择需要的字符集。

Here is a list of some measurements that we have made:

* If you link dynamically (without -static), the result is 13%

slower on Linux. Note that you still can use a dynamically

linked MySQL library for your client applications. It is the

server that is most critical for performance.

* For a connection from a client to a server running on the same

host, if you connect using TCP/IP rather than a Unix socket

file, performance is 7.5% slower. (On Unix, if you connect to

the host name localhost, MySQL uses a socket file by default.)

* For TCP/IP connections from a client to a server, connecting

to a remote server on another host is 8% to 11% slower than

connecting to a server on the same host, even for connections

faster than 100Mb/s Ethernet.

* When running our benchmark tests using secure connections (all

data encrypted with internal SSL support) performance was 55%

slower than with unencrypted connections.

* On a Sun UltraSPARC-IIe, a server compiled with Forte 5.0 is

4% faster than one compiled with gcc 3.2.

* On a Sun UltraSPARC-IIe, a server compiled with Forte 5.0 is

4% faster in 32-bit mode than in 64-bit mode.

* Compiling on Linux-x86 using gcc without frame pointers

(-fomit-frame-pointer or -fomit-frame-pointer -ffixed-ebp)

makes mysqld 1% to 4% faster.

这段保留一点原汁原味

mysql 5.74安装教程_MySQL安装、基本账户安全(5.0以后版本)相关推荐

  1. kali mysql安装教程_MySQL 安装教程(windows版)

    MySQL版本:8.0.18 window环境:win10 1.首先我们需要下载ZIP解压配置安装包,如果有需要的可以到下面网址下载. 2.将安装包下载至F盘中新建的my_sql文件夹中并解压 3.配 ...

  2. mysql8.0.17压缩包安装教程_超详细的MySQL8.0.17版本安装教程

    下载MySQL 如下图所示: 然后点击DOWNLOADS ==> Community,选择MySQL Community Server.如图所示: 滑到页面的最下面,找到Recommended ...

  3. mysql5 7安装教程_MySQL57安装教程

    MySQL57安装教程... --------------------------- 首先需要下载MySQL57安装包: --------------------------------------- ...

  4. MinGW-w64安装教程——著名C/C++编译器GCC的Windows版本

    基本操作就是将下面下载的任意版本解压到你想安装的目录而后将bin 添加到环境变量即可 https://download.csdn.net/download/weixin_32759777/850205 ...

  5. python的安装教程-python安装教程 Pycharm安装详细教程

    python安装教程和Pycharm安装详细教程,分享给大家. 首先我们来安装python 1.首先进入网站下载:点击打开链接(或自己输入网址https://www.python.org/downlo ...

  6. python详细安装教程3.7.0-python 3.7.0 安装配置方法图文教程

    本文记录了python 3.7.0 安装配置方法,供大家参考,具体内容如下 S1登入Python官网下载网址 S2下载后缀为exe的可执行文件,并根据自己电脑/主机的系统选择32位还是64位. 双击选 ...

  7. python3.7.3安装教程和配置idle_python 3.7.0 安装配置方法图文教程

    本文记录了python 3.7.0 安装配置方法,供大家参考,具体内容如下 S1登入Python官网下载网址 S2下载后缀为exe的可执行文件,并根据自己电脑/主机的系统选择32位还是64位. 双击选 ...

  8. python安装教程-python安装教程 Pycharm安装详细教程

    python安装教程和Pycharm安装详细教程,分享给大家. 首先我们来安装python 1.首先进入网站下载:点击打开链接(或自己输入网址https://www.python.org/downlo ...

  9. 解决M1芯片无法安装AE闪退问题,AEcc2021中文直装版兼容M1芯片安装教程 M1安装方案

    Adobe After Effects 2021 mac M1版上线啦!ae2021 mac中文版是ae Mac的最新版本,全新优化专为Mac用户设计,让不可能变为可能.ae 2021 mac破解版下 ...

最新文章

  1. iOS下JS与OC互相调用(六)--WKWebView + WebViewJavascriptBridge
  2. emacs 跳转到指定行
  3. 战神引擎修改服务器时间,修改战神引擎手游进入游戏公告内容教程
  4. java监听器用法(二):窗口监听器
  5. RocketMQ简介、环境搭建
  6. 网络编辑日常工作的内容有哪些?
  7. 学习:java设计模式—工厂模式
  8. jQuery操作DOM元素案例
  9. 头条号个人中心登录_头条号平台上线「插入小程序」功能
  10. [置顶]       IE与FireFox的JavaScript兼容问题
  11. JavaScript==比较的规则
  12. 日期和时间的正则表达式
  13. 智迈职称计算机一练通破解版,智迈初级会计职称考试软件
  14. 教你批量采集晨光文具的商品图片到电脑中
  15. JAVA子类与继承 实验实列
  16. 使用bat批处理脚本自动设置IP和IE代理
  17. 感谢题主给我一个反思失败的机会。
  18. 如何搭建一个机器人控制系统
  19. 压铸人的火眼金睛 | 智铸超云案例分享
  20. 服务器机箱装系统蓝屏,电脑安装系统,容易出现蓝屏、死机等5大问题,装机达人给你支招...

热门文章

  1. linux之类似Windows的资源管理器gnome-system-monitor(可用这个杀死进程)
  2. Bit Manipulation —— 位运算
  3. Android插件化开发之动态加载基础之ClassLoader工作机制
  4. Android之二维码扫描的总结
  5. 工业相机和普通相机的区别详解_数码单反相机和胶片单反相机的区别
  6. 软件项目管理课后题下载【共5个章(1、3、4、5、6)】
  7. 神还原女神照片!GAN为百年旧照上色
  8. 面试算法工程师时,我居然被化学专业转行的老哥血虐了
  9. inputn函数与input函数的区别
  10. 刷magisk模块后不能开机_刷Magisk模块开机卡Logo了怎么办?两种方法教你轻松解决...