您好,欢迎来到保捱科技网。
搜索
您的当前位置:首页CentOS Mysql安装与系统建立用户组

CentOS Mysql安装与系统建立用户组

来源:保捱科技网
CentOS Mysql安装与系统建立用

户组 

这里讲解CentOS󰀃Mysql安装。CentOS󰀃Linux的稳定性不比RHEL差,唯一不足的就是缺乏技术支持,因为它是由社区发布的免费版。󰀃

1、建立CentOS Mysql用户组 

󰀃󰀃[root@localhost󰀃~]#󰀃grep󰀃mysql󰀃/etc/group󰀃󰀃󰀃#查询系统中是否有mysql这个用户组,没有则添加。󰀃󰀃󰀃[root@localhost󰀃~]#󰀃groupadd󰀃mysql󰀃󰀃󰀃#增加一个名为CentOS󰀃Mysql的用户组󰀃

2、建立CentOS Mysql用户 

󰀃󰀃[root@localhost󰀃~]#󰀃grep󰀃mysql󰀃/etc/passwd󰀃󰀃󰀃#查询系统中是否有mysql这个用户,没有则添加。󰀃

󰀃󰀃[root@localhost󰀃~]#󰀃useradd󰀃mysql󰀃-g󰀃mysql󰀃-M󰀃-s󰀃/sbin/nologin󰀃󰀃󰀃#增加一个名为CentOS󰀃Mysql的用户。󰀃󰀃󰀃-g:指定新用户所属的用户组(group)󰀃󰀃󰀃-M:不建立根目录󰀃

󰀃󰀃-s:定义其使用的shell,/sbin/nologin代表用户不能登录系统。󰀃

3、下载:mysql-4.0.26 

󰀃󰀃[root@localhost󰀃~]#󰀃cd󰀃/usr/local/src/󰀃󰀃󰀃[root@localhost󰀃src]#󰀃wget󰀃

󰀃󰀃http://ftp.gamearena.cn/software/mysql-4.0.26.tar.gz󰀃󰀃󰀃#......(信息略)......󰀃

󰀃󰀃[root@localhost󰀃src]#󰀃chmod󰀃+x󰀃mysql-4.0.26.tar.gz󰀃󰀃󰀃#修改文件权限为755󰀃

󰀃󰀃[root@localhost󰀃src]#󰀃tar󰀃-zxvf󰀃mysql-4.0.26.tar.gz󰀃󰀃󰀃#......(信息略)......󰀃󰀃󰀃#解压缩󰀃

󰀃󰀃PS:当你在󰀃󰀃󰀃www.mysql.com󰀃

󰀃󰀃下载CentOS󰀃Mysql安装的时候,会发现有binary/rpm/source三种包。binary󰀃distribution是由mysql官方优化编译好的,不需要make。󰀃

4、设置CentOS Mysql安装编译器的编译参数 

󰀃󰀃[root@localhost󰀃src]#󰀃cd󰀃/usr/local/src/mysql-4.0.26󰀃

󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃./configure󰀃--prefix=/usr/local/mysql󰀃--with-unix-socket-path=/tmp/mysql.sock󰀃--localstatedir=/usr/local/mysql/data󰀃--with-charset=gbk󰀃--without-debug󰀃--enable-assembler󰀃--without-isam󰀃--with-client-ldflags=-all-static󰀃--with-mysqld-ldflags=-all-static󰀃󰀃󰀃#这些设置告诉编译器如何编译apache:󰀃󰀃󰀃--prefix=/usr/local/mysql󰀃󰀃󰀃指定CentOS󰀃Mysql安装目录󰀃

󰀃󰀃--with-unix-socket-path=/tmp/mysql.sock󰀃

󰀃󰀃这个是指定CentOS󰀃Mysql安装服务器启动后,联机套接字文件所处的位置和文件名。󰀃󰀃󰀃--localstatedir=/usr/local/mysql/data󰀃󰀃󰀃指定CentOS󰀃Mysql安装的数据库目录󰀃󰀃󰀃--with-charset=gbk󰀃󰀃󰀃添加gbk中文字符支持󰀃󰀃󰀃--without-debug󰀃󰀃󰀃去除debug模式󰀃󰀃󰀃--enable-assembler󰀃󰀃󰀃使用一些字符函数的汇编版本󰀃󰀃󰀃--without-isam󰀃

󰀃󰀃去掉isam表类型支持,现在很少用了,isam表是一种依赖平台的表󰀃󰀃󰀃--with-client-ldflags=-all-static󰀃󰀃󰀃--with-mysqld-ldflags=-all-static󰀃

5、编译和CentOS Mysql安装 

󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃make󰀃

󰀃󰀃#“make”命令把源文件编译成可执行的二进制文件󰀃

󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃make󰀃install󰀃

󰀃󰀃#“make󰀃install”把二进制文件和配置文件安装在合适的目录下󰀃

6、初始化系统库 

󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃./scripts/mysql_install_db󰀃

7、CentOS Mysql安装其它设置 

󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃cp󰀃support-files/my-medium.cnf󰀃/etc/my.cnf󰀃-fv󰀃󰀃󰀃#注解:󰀃

󰀃󰀃-f,删除目标中同名的文件或目录,并且不给任何提示。󰀃

󰀃󰀃#还有一些其它的my.cnf配置文件。适合不同的应用规模。型式如my-*.cnf。根据自己的需要cp。󰀃󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃cp󰀃support-files/mysql.server󰀃/etc/init.d/mysqld󰀃󰀃󰀃#添加到起动脚本󰀃

󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃chmod󰀃700󰀃/etc/init.d/mysqld󰀃󰀃󰀃[root@localhost󰀃mysql-4.0.26]#󰀃cd󰀃/usr/local󰀃󰀃󰀃[root@localhost󰀃local]#󰀃chmod󰀃750󰀃mysql󰀃-R󰀃󰀃󰀃#注解:󰀃

󰀃󰀃-R󰀃递归改变目录及其内容的权限。󰀃

󰀃󰀃[root@localhost󰀃local]#󰀃chown󰀃-R󰀃mysql.mysql󰀃/usr/local/mysql󰀃

󰀃󰀃#设置所有者,CentOS󰀃Mysql起动时会以CentOS󰀃Mysql安装用户的身份运行,这样可以提高系统的安全性。󰀃

󰀃󰀃[root@localhost󰀃local]#󰀃chown󰀃-R󰀃mysql.mysql󰀃/usr/local/mysql/data󰀃󰀃󰀃[root@localhost󰀃local]#󰀃cd󰀃/usr/local/mysql/libexec󰀃󰀃󰀃[root@localhost󰀃libexec]#󰀃cp󰀃mysqld󰀃mysqld.old󰀃󰀃󰀃[root@localhost󰀃libexec]#󰀃strip󰀃mysqld󰀃

󰀃󰀃[root@localhost󰀃libexec]#󰀃chkconfig󰀃--add󰀃mysqld󰀃󰀃󰀃#添加一个服务󰀃

󰀃󰀃[root@localhost󰀃libexec]#󰀃chkconfig󰀃--level󰀃345󰀃mysqld󰀃on󰀃󰀃󰀃#设置开机时起动󰀃

󰀃󰀃[root@localhost󰀃libexec]#󰀃service󰀃mysqld󰀃start󰀃󰀃󰀃#启动CentOS󰀃Mysql安装服务󰀃

󰀃󰀃[root@localhost󰀃libexec]#󰀃ln󰀃-s󰀃/usr/local/mysql/bin/mysql󰀃/sbin/mysql󰀃

󰀃󰀃[root@localhost󰀃libexec]#󰀃ln󰀃-s󰀃/usr/local/mysql/bin/mysqladmin󰀃/sbin/mysqladmin󰀃󰀃󰀃[root@localhost󰀃libexec]#󰀃ln󰀃-s󰀃/usr/local/mysql/bin/mysqldump󰀃/sbin/mysqldump󰀃󰀃󰀃[root@localhost󰀃libexec]#󰀃mysqladmin󰀃-uroot󰀃password󰀃\"youpassword\"󰀃󰀃󰀃#设置root帐户的密码󰀃

󰀃󰀃[root@localhost󰀃libexec]#󰀃mysql󰀃-uroot󰀃-p󰀃󰀃󰀃#󰀃输入你设置的密码󰀃󰀃󰀃mysql>use󰀃mysql;󰀃

󰀃󰀃mysql>delete󰀃from󰀃user󰀃where󰀃password=\"\";󰀃󰀃󰀃#删除用于本机匿名连接的空密码帐号󰀃󰀃󰀃mysql>flush󰀃privileges;󰀃󰀃󰀃mysql>󰀃show󰀃databases;󰀃󰀃󰀃+----------+󰀃󰀃󰀃|󰀃Database󰀃|󰀃󰀃󰀃+----------+󰀃󰀃󰀃|󰀃mysql󰀃|󰀃󰀃󰀃|󰀃test󰀃|󰀃󰀃󰀃+----------+󰀃

󰀃󰀃2󰀃rows󰀃in󰀃set󰀃(0.08󰀃sec)󰀃

󰀃󰀃#显示一下数据库,测试CCentOS󰀃Mysql安装正常。󰀃󰀃󰀃mysql>󰀃quit󰀃󰀃

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- baoaiwan.cn 版权所有 赣ICP备2024042794号-3

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务