kxbin
成功留给有准备的人
posts - 10,  comments - 35,  trackbacks - 0

一.下载mysql-5.1.45.tar.gz
http://dev.mysql.com/downloads
或其它地方下载

二.添加mysql用户及mysql用户组,并把mysql用户放到mysql用户组中
useradd mysql
等与用下面两条命令:
groupadd mysql
useradd -g mysql mysql

三.上传到/usr/local/src下(方便管理)解压安装
[root@localhost src]# tar -zxvf mysql-5.1.45.tar.gz
[root@localhost src]# cd mysql-5.1.45

1.编译
[root@localhost mysql-5.1.45]# ./configure --prefix=/usr/local/mysql --with-charset=gbk --with-collation=gbk_chinese_ci --with-extra-charsets=all --with-named-curses-libs=/usr/lib/libncurses.so.5
2.安装
[root@localhost mysql-5.1.45]# make && make install (这个时间比较长)

3.将mysql加入到系统变量path中
将/usr/local/mysql/bin 加入到path中,这样在shell里就可以运行mysql相关的命令。
[root@localhost mysql-5.1.45]# vi /etc/profile
加入
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH

如果同时安装tomcat可以采用下面的方式
export TOMCAT_HOME=/home/coomix/apache-tomcat-5.5.27
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:TOMCAT_HOME/bin:$PATH

[root@localhost mysql-5.1.45]# source /etc/profile 使配置文件立即生效

4.进入到mysql文件夹下,初始化mysql表格,安装 mysql 默认数据库
[root@localhost mysql-5.1.45]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin docs include lib libexec mysql-test share sql-bench
[root@localhost mysql]# mysql_install_db --user=mysql

5.修改目录权限
[root@localhost mysql]# chown -R root:mysql .
[root@localhost mysql]# chown -R mysql var
[root@localhost mysql]# chgrp -R mysql .

6.修改配置,将mysql加入系统服务:
[root@localhost mysql]# cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
[root@localhost mysql]# cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld

 

7.启动mysql
[root@localhost mysql]# service mysqld
Usage: /etc/init.d/mysqld {start|stop|restart|reload|force-reload|status} [ MySQL server options ]
[root@localhost mysql]# service mysqld start
Starting MySQL.                                            [确定]
[root@localhost mysql]#

8.使用mysql,默认root用户是没有密码的
[root@localhost mysql]# cd bin
[root@localhost bin]# ./mysql -u root -p
Enter password: 直接按回车
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.45-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

9.修改root密码
[root@localhost bin]# mysqladmin -u root password 'root'
[root@localhost bin]# mysqladmin -u root -h host_name password 'root'
mysqladmin: connect to server at 'host_name' failed
error: 'Unknown MySQL server host 'host_name' (1)'
Check that mysqld is running on host_name and that the port is 3306.
You can check this by doing 'telnet host_name 3306'
[root@localhost bin]# ./mysql -u root -p
Enter password: 输入root
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.01 sec)

mysql> use mysql;
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
23 rows in set (0.00 sec)

mysql> quit
Bye
[root@localhost bin]#


附:[root@localhost mysql]# mysql_install_db --user=mysql执行后的显示:
Installing MySQL system tables...
OK
Filling help tables...
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:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/local/mysql/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 /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

posted on 2012-01-11 16:37 kxbin 阅读(1021) 评论(0)  编辑  收藏 所属分类: MYSQLLinux

只有注册用户登录后才能发表评论。


网站导航:
 
你恨一个人是因为你爱他;你喜欢一个人,是因为他身上有你没有的;你讨厌一个人是因为他身上有你有的东西;你经常在别人面前批评某人,其实潜意识中是想接近他。

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

相册

收藏夹

J2EE

java技术网站

Linux

平时常去的网站

数据库

电影网站

网站设计

搜索

  •  

最新评论

阅读排行榜

评论排行榜