既有环境:

1)下载MySQL Community Server 5.6.17 压缩版(mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz)

2)安装目录: /opt/library/mysql-5.6.17-linux-glibc2.5-x86_64

3)软链接为/opt/library/mysql,指向同目录下的mysql-5.6.17-linux-glibc2.5-x86_64

1. 创建mysql专有的用户和组

$ sudo groupadd mysql
$ sudo useradd -r -g mysql mysql

2. 修改mysql文件夹及软链接的owner

$ sudo chown -R mysql:mysql mysql-5.6.17-linux-glibc2.5-x86_64/
$ sudo chown -R mysql:mysql mysql

3. 使用mysql_install_db初始化授权表。此操作只是在MySQL初次安装时才需要执行,如果是已存在的安装,则可以跳过此步骤,否则会覆盖先前的授权信息。

$ sudo scripts/mysql_install_db --user=mysql

4. 发现mysql_install_db执行有错误。看错误提示,原来是因为缺少共享库libaio1。

xuyuzhu@xuyuzhu-OptiPlex-990:/opt/library/mysql$ sudo scripts/mysql_install_db --user=mysql
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

5. 安装libaio1

$ sudo apt-get install libaio1

6. 重新执行第三步,以下是几行关键log

Installing MySQL system tables...2014-05-15 14:43:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

.
.
创建第一张数据表、表大小、buffer、fk、log文件
.
Filling help tables...2014-05-15 14:43:52 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). .
.
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: ./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h xuyuzhu-OptiPlex-990 password 'new-password' Alternatively you can run: ./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 . ; ./bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl .
.

总结下:
1)support-files/mysql.server用于启动mysql
2)可用 mysqladmin 或 mysql_secure_installation 命令修改密码
3)可以使用"cd . ; ./bin/mysqld_safe &"配置mysql守护进程

7. 添加mysql启动脚本软链接

$ cd /etc/init.d/
$ sudo ln -s /opt/library/mysql/support-files/mysql.server

8. 启动mysql服务

xuyuzhu@xuyuzhu-OptiPlex-990:/etc/init.d$ ./mysql.server start
/etc/init.d/mysql.server: 1: /etc/init.d/mysql.server: my_print_defaults: not found
/etc/init.d/mysql.server: 276: cd: can't cd to /usr/local/mysql
Starting MySQL
* Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

9. 报错。因为mysql.server里读取mysql的目录是/user/local/mysql,所以在/user/local/中创建一个,mysql的软链接到/opt/library/mysql。再执行第8步。

$ ln -s /opt/library/mysql /usr/local/mysql
$ sudo chown mysql:mysql /usr/local/mysql
$ sudo ./mysql.server start
# 上面必须使用sudo权限启动, 不然会报 . * The server quit without updating PID file (/usr/local/mysql/data/xuyuzhu-OptiPlex-990.pid).
Starting MySQL

10. ps检查进程

xuyuzhu@xuyuzhu-OptiPlex-990:/etc/init.d$ ps -aux |grep mysql
root 373 0.0 0.0 4444 744 pts/13 S 15:16 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/xuyuzhu-OptiPlex-990.pid
mysql 484 2.4 11.4 976004 448164 pts/13 Sl 15:16 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/xuyuzhu-OptiPlex-990.err --pid-file=/usr/local/mysql/data/xuyuzhu-OptiPlex-990.pid
xuyuzhu 511 0.0 0.0 15960 916 pts/13 S+ 15:16 0:00 grep --color=auto mysql

11. mysqladmin检查是否可以使用mysql

$ mysqladmin version
mysqladmin Ver 8.42 Distrib 5.6.17, for linux-glibc2.5 on x86_64
Copyright (c) 2000, 2014, 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. Server version5.6.17
Protocol version10
ConnectionLocalhost via UNIX socket
UNIX socket/tmp/mysql.sock
Uptime:4 min 48 sec Threads: 1 Questions: 2 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.006

12. 添加开机启动mysql服务守护进程

xuyuzhu@xuyuzhu-OptiPlex-990:/etc/init.d$ sudo update-rc.d mysql.server defaults
Adding system startup for /etc/init.d/mysql.server ...
/etc/rc0.d/K20mysql.server -> ../init.d/mysql.server
/etc/rc1.d/K20mysql.server -> ../init.d/mysql.server
/etc/rc6.d/K20mysql.server -> ../init.d/mysql.server
/etc/rc2.d/S20mysql.server -> ../init.d/mysql.server
/etc/rc3.d/S20mysql.server -> ../init.d/mysql.server
/etc/rc4.d/S20mysql.server -> ../init.d/mysql.server
/etc/rc5.d/S20mysql.server -> ../init.d/mysql.server

13. that’s all.

参考http://www.cnblogs.com/eastson/archive/2012/06/09/2543489.html

ps. Redhat启动mysql服务: /etc/init.d/mysqld start

最新文章

  1. 『.NET Core CLI工具文档』(二).NET Core 工具遥测(应用信息收集)
  2. T-SQL Recipes之生成动态列表数据
  3. spine实现预加载(一)
  4. 细数.NET 中那些ORM框架 —— 谈谈这些天的收获之一
  5. Struts2 源码分析——过滤器(Filter)
  6. adobeMediaServer
  7. Python [Leetcode 342]Power of Four
  8. Python中exec的使用
  9. PowerShell 脚本执行策略
  10. [LeetCode] Cracking the Safe 破解密码
  11. CSharpGL(49)试水OpenGL软实现
  12. 【二代示波器教程】第12章 示波器设计—DAC信号发生器的实现
  13. 404.17 - 动态内容通过通配符 MIME 映射映射到静态文件处理程序
  14. SecureCRT中sqlplus,使用Backspace删除时 ^H^H
  15. SSM框架接收处理安卓端的json数据
  16. 53题看透java线程
  17. node.js fs、http使用
  18. python操作Hbase
  19. Jq_input file标签上传图片到服务器
  20. java基础---->Base64算法的使用

热门文章

  1. 转一篇pgpool配置
  2. 前端画图之iphoneSE主屏
  3. 抓https包
  4. 第2章 开始Flex
  5. 卷积神经网络实战-----0001(移植卷积神经网络c++ to python or java)
  6. windows 下后台启动 redis
  7. POJ 2029 Palindromes _easy version
  8. 第九集 经验风险最小化(ERM)
  9. spring的笔记1 关云长
  10. 【spring源码学习】spring的IOC容器之自定义xml配置标签扩展namspaceHandler向IOC容器中注册bean