怎么实现脚本安装mysql mysql一键安装脚本( 五 )


[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
2.安装MySQL的服务器端软件 , 注意切换到root用户:
[root@localhost JavaEE]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm
安装完成后,安装进程会在Linux中添加一个mysql组,以及属于mysql组的用户mysql 。可通过id命令查看:
[root@localhost JavaEE]#id mysql
uid=496(mysql)gid=493(mysql) groups=493(mysql)
MySQL服务器安装之后虽然配置了相关文件 , 但并没有自动启动mysqld服务,需自行启动:
[root@localhost JavaEE]#service mysql start
Starting MySQL.. SUCCESS!
可通过检查端口是否开启来查看MySQL是否正常启动:
[root@localhost JavaEE]#netstat -anp|grep 3306
tcp00 0.0.0.0:33060.0.0.0:*LISTEN34693/mysqld
c.安装MySQL的客户端软件:
[root@localhost JavaEE]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm
如果安装成功应该可以运行mysql命令,注意必须是mysqld服务以及开启:
[root@localhost JavaEE]#mysql
Welcome to the MySQLmonitor.Commands end with ; or \g.
Your MySQL connection idis 1
Server version: 5.5.29MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademarkof Oracle Corporation and/or its affiliates. Other names may be trademarks oftheir respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql
d.RPM安装方式文件分布
Directory
Contents of Directory
/usr/bin
Client programs and scripts
/usr/sbin
The mysqld server
/var/lib/mysql
Log files, databases
/usr/share/info
Manual in Info format
/usr/share/man
Unix manual pages
/usr/include/mysql
Include (header) files
/usr/lib/mysql
Libraries
/usr/share/mysql
Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/usr/share/sql-bench
Benchmarks
如何将mysql数据库同程序一同打包实现用户一键安装?不用写脚本啦,我实现过,直接把MySQL文件夹和你的程序一块打包,将MySQL文件夹里面的my.ini文件修改为对应的你打包后将要安装的MySQL文件夹位置就Ok了 。我用的打包软件是setup factory7.0.
Ubuntu手动安装MySQL从下载安装包MySQL :: Download MySQL Community Server
解压到/usr/local目录下 , 重命名为mysql
然后在终端输入以下命令:
shell groupadd mysql
shell useradd -r -g mysql mysql
shell cd /usr/local
shell cd mysql
shell chown -R mysql . (别忘了最后有一个点,下同)
shell chgrp -R mysql .
shell scripts/mysql_install_db --user=mysql
这句执行后如果报错:
scripts/mysql_install_db: 244: ./bin/my_print_defaults: not found
Neither host 'ubuntu' nor 'localhost' could be looked up with
./bin/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option
在终端输入uname -a命令查看系统版本,如果结果为x86_64则说明系统是64位的 , 是不是下载的安装包不对了?到下载64位版本的,把刚解压到mysql目录删掉,重新执行上面这一条语句
如果又报错:./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
这说明少个东西,执行下面这条命令:
sudo apt-get install libaio-dev
安装完成后再执行scripts/mysql_install_db --user=mysql这条语句
继续执行后续命令:
shell chown -R root .
shell chown -R mysql data

推荐阅读