MySQL 安装与使用(一)
操作系统:CentOS release 5.10 (Final)
文件准备:
MySQL-server-community-5.1.73-1.rhel5.i386.rpm
MySQL-client-community-5.1.73-1.rhel5.i386.rpm
一、安装MySQL
rpm包安装:
切换到包所在目录,执行:
rpm -i MySQL-server-community-5.1.73-1.rhel5.i386.rpm rpm -i MySQL-client-community-5.1.73-1.rhel5.i386.rpm
完成后MySQL的顶级安装目录为/usr。注意,如果只是安装了MySQL-server的话,在这些路径中像mysql、mysqladmin等是没有的,也是无法使用的。
/etc/init.d/mysql
/etc/logrotate.d/mysql
/etc/my.cnf
/etc/mysqlmanager.passwd
/usr/bin/innochecksum
/usr/bin/my_print_defaults
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql_convert_table_format
/usr/bin/mysql_fix_extensions
/usr/bin/mysql_fix_privilege_tables
/usr/bin/mysql_install_db
/usr/bin/mysql_secure_installation
/usr/bin/mysql_setpermission
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysql_zap
/usr/bin/mysqlbug
/usr/bin/mysqld_multi
/usr/bin/mysqld_safe
/usr/bin/mysqldumpslow
/usr/bin/mysqlhotcopy
/usr/bin/mysqltest
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolve_stack_dump
/usr/bin/resolveip
/usr/lib/mysql/mysqld-debug.sym
/usr/lib/mysql/mysqld.sym
/usr/lib/mysql/plugin/ha_innodb_plugin.so
/usr/lib/mysql/plugin/ha_innodb_plugin.so.0
/usr/lib/mysql/plugin/ha_innodb_plugin.so.0.0.0
/usr/sbin/mysqld
/usr/sbin/mysqld-debug
/usr/sbin/mysqlmanager
/usr/sbin/rcmysql
/usr/share/doc/MySQL-server-community-5.1.73
/usr/share/doc/MySQL-server-community-5.1.73/COPYING
/usr/share/doc/MySQL-server-community-5.1.73/README
/usr/share/doc/MySQL-server-community-5.1.73/my-huge.cnf
/usr/share/doc/MySQL-server-community-5.1.73/my-innodb-heavy-4G.cnf
/usr/share/doc/MySQL-server-community-5.1.73/my-large.cnf
/usr/share/doc/MySQL-server-community-5.1.73/my-medium.cnf
/usr/share/doc/MySQL-server-community-5.1.73/my-small.cnf
/usr/share/info/mysql.info.gz
/usr/share/man/man1/innochecksum.1.gz
/usr/share/man/man1/my_print_defaults.1.gz
/usr/share/man/man1/myisam_ftdump.1.gz
/usr/share/man/man1/myisamchk.1.gz
/usr/share/man/man1/myisamlog.1.gz
/usr/share/man/man1/myisampack.1.gz
/usr/share/man/man1/mysql.server.1.gz
/usr/share/man/man1/mysql_convert_table_format.1.gz
/usr/share/man/man1/mysql_fix_extensions.1.gz
/usr/share/man/man1/mysql_fix_privilege_tables.1.gz
/usr/share/man/man1/mysql_install_db.1.gz
/usr/share/man/man1/mysql_secure_installation.1.gz
/usr/share/man/man1/mysql_setpermission.1.gz
/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
/usr/share/man/man1/mysql_upgrade.1.gz
/usr/share/man/man1/mysql_zap.1.gz
/usr/share/man/man1/mysqlbug.1.gz
/usr/share/man/man1/mysqld_multi.1.gz
/usr/share/man/man1/mysqld_safe.1.gz
/usr/share/man/man1/mysqldumpslow.1.gz
/usr/share/man/man1/mysqlhotcopy.1.gz
/usr/share/man/man1/mysqlman.1.gz
/usr/share/man/man1/mysqltest.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man8/mysqld.8.gz
/usr/share/man/man8/mysqlmanager.8.gz
/usr/share/mysql
/usr/share/mysql/ChangeLog
/usr/share/mysql/SELinux
/usr/share/mysql/SELinux/RHEL4
/usr/share/mysql/SELinux/RHEL4/mysql.fc
/usr/share/mysql/SELinux/RHEL4/mysql.te
/usr/share/mysql/binary-configure
/usr/share/mysql/charsets
/usr/share/mysql/charsets/Index.xml
/usr/share/mysql/charsets/README
/usr/share/mysql/charsets/armscii8.xml
/usr/share/mysql/charsets/ascii.xml
/usr/share/mysql/charsets/cp1250.xml
/usr/share/mysql/charsets/cp1251.xml
/usr/share/mysql/charsets/cp1256.xml
/usr/share/mysql/charsets/cp1257.xml
/usr/share/mysql/charsets/cp850.xml
/usr/share/mysql/charsets/cp852.xml
/usr/share/mysql/charsets/cp866.xml
/usr/share/mysql/charsets/dec8.xml
/usr/share/mysql/charsets/geostd8.xml
/usr/share/mysql/charsets/greek.xml
/usr/share/mysql/charsets/hebrew.xml
/usr/share/mysql/charsets/hp8.xml
/usr/share/mysql/charsets/keybcs2.xml
/usr/share/mysql/charsets/koi8r.xml
/usr/share/mysql/charsets/koi8u.xml
/usr/share/mysql/charsets/latin1.xml
/usr/share/mysql/charsets/latin2.xml
/usr/share/mysql/charsets/latin5.xml
/usr/share/mysql/charsets/latin7.xml
/usr/share/mysql/charsets/macce.xml
/usr/share/mysql/charsets/macroman.xml
/usr/share/mysql/charsets/swe7.xml
/usr/share/mysql/config.huge.ini
/usr/share/mysql/config.medium.ini
/usr/share/mysql/config.small.ini
/usr/share/mysql/czech
/usr/share/mysql/czech/errmsg.sys
/usr/share/mysql/danish
/usr/share/mysql/danish/errmsg.sys
/usr/share/mysql/dutch
/usr/share/mysql/dutch/errmsg.sys
/usr/share/mysql/english
/usr/share/mysql/english/errmsg.sys
/usr/share/mysql/errmsg.txt
/usr/share/mysql/estonian
/usr/share/mysql/estonian/errmsg.sys
/usr/share/mysql/fill_help_tables.sql
/usr/share/mysql/french
/usr/share/mysql/french/errmsg.sys
/usr/share/mysql/german
/usr/share/mysql/german/errmsg.sys
/usr/share/mysql/greek
/usr/share/mysql/greek/errmsg.sys
/usr/share/mysql/hungarian
/usr/share/mysql/hungarian/errmsg.sys
/usr/share/mysql/italian
/usr/share/mysql/italian/errmsg.sys
/usr/share/mysql/japanese
/usr/share/mysql/japanese/errmsg.sys
/usr/share/mysql/korean
/usr/share/mysql/korean/errmsg.sys
/usr/share/mysql/mi_test_all
/usr/share/mysql/mi_test_all.res
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/mysql-log-rotate
/usr/share/mysql/mysql.server
/usr/share/mysql/mysql_fix_privilege_tables.sql
/usr/share/mysql/mysql_system_tables.sql
/usr/share/mysql/mysql_system_tables_data.sql
/usr/share/mysql/mysql_test_data_timezone.sql
/usr/share/mysql/mysqld_multi.server
/usr/share/mysql/ndb-config-2-node.ini
/usr/share/mysql/norwegian
/usr/share/mysql/norwegian-ny
/usr/share/mysql/norwegian-ny/errmsg.sys
/usr/share/mysql/norwegian/errmsg.sys
/usr/share/mysql/polish
/usr/share/mysql/polish/errmsg.sys
/usr/share/mysql/portuguese
/usr/share/mysql/portuguese/errmsg.sys
/usr/share/mysql/romanian
/usr/share/mysql/romanian/errmsg.sys
/usr/share/mysql/russian
/usr/share/mysql/russian/errmsg.sys
/usr/share/mysql/serbian
/usr/share/mysql/serbian/errmsg.sys
/usr/share/mysql/slovak
/usr/share/mysql/slovak/errmsg.sys
/usr/share/mysql/spanish
/usr/share/mysql/spanish/errmsg.sys
/usr/share/mysql/swedish
/usr/share/mysql/swedish/errmsg.sys
/usr/share/mysql/ukrainian
/usr/share/mysql/ukrainian/errmsg.sys
/usr/bin/msql2mysql
/usr/bin/mysql
/usr/bin/mysql_find_rows
/usr/bin/mysql_waitpid
/usr/bin/mysqlaccess
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlshow
/usr/bin/mysqlslap
/usr/share/man/man1/msql2mysql.1.gz
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysql_find_rows.1.gz
/usr/share/man/man1/mysql_waitpid.1.gz
/usr/share/man/man1/mysqlaccess.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqlbinlog.1.gz
/usr/share/man/man1/mysqlcheck.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlimport.1.gz
/usr/share/man/man1/mysqlshow.1.gz
/usr/share/man/man1/mysqlslap.1.gz
rpm -ql MySQL-server-community-5.1.73-1.rhel5 MySQL-client-community-5.1.73-1.rhel5
二、安装完成后的相关配置
1.运行mysql_install_db 程序设置含有确定如何让用户连接服务器的权限的初始MySQL授权表。
/usr/bin/mysql_install_db --user=root
mysql_install_db脚本创建数据目录、拥有所有数据库权限的mysql数据库和可以用来测试MySQL的test数据库。脚本为root账户和匿名用户账户创建 授权表条目。
2.启动数据库。
/usr/bin/mysqld_safe --user=mysql &
3.配置数据库
为数据库设定一个密码(初始为空):
/usr/bin/mysqladmin -u root password 'new-password'
卸掉test数据库:
/usr/bin/mysqladmin -u root drop test
以上两个操作可以由mysql_secure_installation脚本代替:
/usr/bin/mysql_secure_installation
其功能包括:
Change the root password?
Remove anonymous users?
Disallow root login remotely?
Remove test database and access to it?
Reload privilege tables now?
4.关闭数据库
/etc/init.d/mysql stop
或
mysqadmin shutdown -uroot -p
5.自动启动数据库
如果④中/etc/init.d/mysql存在或有效,则数据库很可能是已经自动启动的,用以下方法确认:
[root@localhost ~]# chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
如果能够列出mysql的启动状态,而且至少3和4为on,则说明mysql能够自动启动。如不能,接着配置:
cd /usr/share/mysql/ cp mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql chkconfig --addMySQL chkconfig --level 345MySQL on
在配置自动启动数据库可能会遇到的问题:
当执行
/etc/init.d/mysql
时出现
Starting MySQL.Manager of pid-file quit without updating file [Failed]
查询日志:
cat /var/lib/mysql/localhost.localdomain.err
有错误
/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
140507 21:38:01 [ERROR] Aborting
而这时,执行
/etc/init.d/mysql --user=root
带上参数user是没问题的(--user=root或--user=mysql)
解决办法:
chgrp -R mysql /var/lib/mysql/
chown -R mysql /var/lib/mysql/
/var/lib/mysql/ 是mysql-bin.index所在的文件夹。
6.匿名账户
①为匿名用户指定密码,可以用SET PASSWORD或UPDATE。在两种情况中,一定要使用PASSWORD()函数为密
码加密。
使用SET PASSWORD方法:
shell> mysql -u root
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');
使用UPDATE直接修改用户表:
shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = '';
mysql> FLUSH PRIVILEGES;
在user表中直接使用UPDATE更新密码后,必须让服务器用FLUSH PRIVILEGES重新读授权表。否则,重新启动服务器
前,不会使用更改。
②删除匿名账户
shell> mysql -u root
mysql> DELETE FROM mysql.user WHERE User = '';
mysql> FLUSH PRIVILEGES;
7.为root账户指定密码
①使用SET PASSWORD语句:
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');
②使用mysqladmin命令行客户端程序:
shell> mysqladmin -u root password "newpwd"
shell> mysqladmin -u root -h host_name password "newpwd"
③使用UPDATE语句:
shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
6.远程连接
①MySQL出于安全因素考虑,默认配置只允许本地登录,打开MySQL配置文件 /etc/mysql/my.cnf,找到 bind-address = 127.0.0.1 修改为 bind-address = 0.0.0.0;
②添加一个远程用户,grant all on *.* to 'userRemote'@'192.168.1.111' identified by '123456' with grant option;
grant all on *.* to 'userRemote'@'192.168.1.111' identified by '' with grant option
这样userRemote就可以从地址192.168.1.111来登录MySQL,如果想不限IP,可以将IP地址设为%,这样这个用户从任意地址都可以访问。
③打开对应防火墙(临时),iptables -I INPUT 2 -p tcp --dport 3306 -j ACCEPT。
iptables -I INPUT -p tcp --dport -j ACCEPT
参考与链接:
MySQL5.1参考手册:http://dev.mysql.com/doc/refman/5.1/zh/index.html
MySQL5.1下载地址:http://dev.mysql.com/downloads/mysql/5.1.html#downloads
MySQL 安装与使用(一)的更多相关文章
- linux Mysql 安装及配置
1.准备 cmake-3.6.0.tar.gz bison-3.0.4.tar.gz mysql-5.7.13.tar.gz (http://dev.mysql.com/get/Downloads/M ...
- mysql安装一 --- 源码包安装
1.登陆http://www.mysql.com/ 或者 www.oracle.com 2. 3. 4. 上面如果不能加载,禁用代理软件 5. 6. 7. 8. 9.上传 10.md5校验安装包的完整 ...
- Ubuntu14.04 Django Mysql安装部署全过程
Ubuntu14.04 Django Mysql安装部署全过程 一.简要步骤.(阿里云Ubuntu14.04) Python安装 Django Mysql的安装与配置 记录一下我的部署过程,也方便 ...
- mysql 安装问题
针对免安装版的mysql: 1.启动CMD,在mysql安装目录下 ~\bin\目录下,输入: mysqld -install 安装msyql服务: 2.启动MySQL服务,输入: net st ...
- 001.mysql安装(lnmp)
mysql官方网站:http://dev.mysql.com/downloads/ Linux环境:刚安装的32位的“最小化安装“的CentOS 6.7 mysql版本:本次实验安装的是mysql5. ...
- MySQL安装步骤
MySQL安装步骤 1. 下载MySQL Community Server 5.6.21,注意选择系统类型(32位/64位) 2. 解压MySQL压缩包 将以下载的MySQL压缩包解压到自定义目录下. ...
- mysql安装配置
MySQL 是最流行的关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司. MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言. MySQL由于其体积小.速度快 ...
- LNMP平台搭建---MySQL安装篇
在前两篇中,安装了一个基本的Web服务器,但是只能提供静态网页查看,要做成动态网站,就必须要数据库或其他编程语言支持了,这里先介绍MySQL数据库的安装. MySQL是一个开源的数据库,在互联网行业应 ...
- MySQL的下载与安装 和 navicat for mysql 安装使用
新手上路-MySQL安装 目录结构 Windows平台 MySQL安装 示例数据导入 Linux平台 CentOS系统 Ubuntu系统 FAQ 密码生成工具-keepass 修改提示符 图形工具 删 ...
- MySQL 安装 + 精简 + 配置
MySQL 安装 + 精简 + 配置 下载安装 从官网 下载 Community Edition MySQL 5.6 版本 精简 根目录下只留 [data/bin/share] , my-defaul ...
随机推荐
- ios 获取当前时间
1.第一种返回的时间是一个整个的字符串. NSDate *timeDate = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateForm ...
- springboot 日志2
SpringBoot关于日志的官方文档 1.简述 SpringBoot官方文档关于日志的整体说明 本博客基于SpringBoot_1.3.6大家请先简单看下这篇英文的官方文档,文中有说 Sprin ...
- Django 实现登陆验证码
一 基本使用方法 Python生成随机验证码,需要使用PIL模块 安装: pip3 install pillow 基本使用 1 创建图片 from PIL import Image, ImageDra ...
- Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead.解决方法
今天在eclipse里报这个错误: Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Please ...
- mySLQ数据库 练习题
MySQL 练习题1 DROP TABLE IF EXISTS `liuyan`; CREATE TABLE `liuyan` ( `id` int(11) NOT NULL AUTO_INCREME ...
- MongoDB安装成为Windows服务及日常使用遇到问题总结
安装MongoDB: http://blog.csdn.net/liuzhoulong/article/details/6124566 严格按照上面的步骤,设置数据库目录,设置日志目录,安装服务.可是 ...
- opencv 形态学操作应用-提取水平与垂直线
adaptiveThreshold(~gray_src, binImg, , ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, , -); #include <ope ...
- sql server 查询不为空的字段
经常用,经常忘 select * from table where content is not null and datalength(content)<>0
- 日期控件 DatePicker 在ie8不能用
过个年,日期控件DatePicker在ie8下突然不能用了,程序也没升级,很是奇怪. 把ie8的“禁用脚本调试”去掉,再次运行,发现提示有脚本错误. 想着可能是兼容性问题,于是把兼容性视图打开运行,还 ...
- 怎么隐藏服务器的IP地址?
服务器一般很少会使用公网地址,直接放置在互联网上使用. 一般是设置成局域网的私网地址,并通过路由器的端口映射,发布在互联网:内部的NAT转换,相当于隐藏了路由器,外网访问并不知道具体服务器的IP地址. ...