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 閱讀(1042) 評論(0)  編輯  收藏 所屬分類: MYSQLLinux
          你恨一個人是因為你愛他;你喜歡一個人,是因為他身上有你沒有的;你討厭一個人是因為他身上有你有的東西;你經常在別人面前批評某人,其實潛意識中是想接近他。

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(5)

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          J2EE

          java技術網站

          Linux

          平時常去的網站

          數據庫

          電影網站

          網站設計

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 图木舒克市| 丹江口市| 和平区| 抚顺县| 剑阁县| 寻乌县| 渝北区| 陇西县| 金坛市| 进贤县| 永新县| 莆田市| 龙口市| 利津县| 海安县| 抚顺县| 深泽县| 伊宁市| 子长县| 达州市| 鹤峰县| 霍山县| 临城县| 谢通门县| 宜春市| 沁水县| 江孜县| 钟祥市| 安平县| 江永县| 靖边县| 全椒县| 芒康县| 法库县| 岑溪市| 剑河县| 灵台县| 梨树县| 上饶市| 来宾市| 江北区|