原创文章,转载请注明出处:http://www.aj2ee.com
Linux下java web服务器搭建(JDK1.6、MySQL5.1、Apache2.2+2Tomcat6+svn1.5)
三、MySQL的安装与配置 1、下载MySQL的安装文件 安装MySQL需要下面两个文件: MySQL-server-community-5.1.61-1.rhel5.i386.rpm MySQL-client-community-5.1.61-1.rhel5.i386.rpm 1)安装服务器端 在有两个rmp文件的目录下运行如下命令: rpm -ivh MySQL-server-community-5.1.61-1.rhel5.i386.rpm
显示如下信息。 2)安装客户端 运行如下命令: rpm -ivh MySQL-client-community-5.1.61-1.rhel5.i386.rpm
显示安装完毕。 2、登录MySQL 登录MySQL的命令是mysql,mysql 的使用语法如下: mysql [-u username] [-h host] [-p[password]] [dbname] username 与 password 分别是 MySQL 的用户名与密码,mysql的初始管理帐号是root,没有密码,注意:这个root用户不是Linux的系统用户。MySQL默认用户是root,由于初始没有密码,第一次进时只需键入mysql即可。
出现了“mysql>”提示符,恭喜你,安装成功! 修改MySQL root用户的密码 MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。 命令usr/bin/mysqladmin -u root password 'new-password' 格式:mysqladmin -u用户名 -p旧密码 password 新密码 示例:mysqladmin -u root password '123456' 这命令的作用是将root用户的密码改成123456 增加了密码后的登录格式如下: mysql -u root -p Enter password: (输入密码) 其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。 注意:这个mysql文件在/usr/bin目录下,与后面讲的启动文件/etc/init.d/mysql不是一个文件。 4. MySQL的几个重要目录 MySQL安装完成后不象SQL Server默认安装在一个目录,它的数据库文件、配置文件和命令文件分别在不同的目录,了解这些目录非常重要,尤其对于Linux的初学者,因为Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学习。 下面就介绍一下这几个目录。 1、数据库目录 /var/lib/mysql/ 2、配置文件 /usr/share/mysql(mysql.server命令及配置文件) 3、相关命令 /usr/bin(mysqladmin mysqldump等命令) 4、启动脚本 /etc/rc.d/init.d/(启动脚本文件mysql的目录) 5.启动与停止 1、启动 MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可。 [root@localhost init.d]# /etc/init.d/mysql start 2、停止 /usr/bin/mysqladmin -u root -p shutdown 3、自动启动 1)察看mysql是否在自动启动列表中 [root@localhost local]# /sbin/chkconfig --list 2)把MySQL添加到你系统的启动服务组里面去 [root@localhost local]# /sbin/chkconfig --add mysql 3)把MySQL从启动服务组里面删除。 [root@localhost local]# /sbin/chkconfig --del mysql 5.MySQL的常用操作。略(数据库的增删改查这里我就不介绍了) |
Linux下java web服务器搭建(MySQL5.1)
最新推荐文章于 2021-10-11 16:06:20 发布