# 安装Mysql数据库,使用通用二进制软件包
# 创建安装Mysql时所需要的用户
[iyunv@station1 ~]# groupadd -r -g 3306 mysql
[iyunv@station1 ~]# useradd -r -g 3306 -u 3306 mysql
[iyunv@station1 ~]# tar xf mysql-5.5.28-linux2.6-x86_64.tar.gz -C /usr/local/
[iyunv@station1 ~]# cd /usr/local/
[iyunv@station1 local]# ln -s mysql-5.5.28-linux2.6-x86_64 mysql
[iyunv@station1 local]# cd mysql
# 修改属主和属组
[iyunv@station1 mysql]# chown -R mysql:mysql ./
[iyunv@station1 mysql]# ll
total 76
drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:56 bin
-rw-r--r-- 1 mysql mysql 17987 Aug 29 2012 COPYING
drwxr-xr-x 4 mysql mysql 4096 Sep 16 15:56 data
drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:55 docs
drwxr-xr-x 3 mysql mysql 4096 Sep 16 15:56 include
-rw-r--r-- 1 mysql mysql 7604 Aug 29 2012 INSTALL-BINARY
drwxr-xr-x 3 mysql mysql 4096 Sep 16 15:56 lib
drwxr-xr-x 4 mysql mysql 4096 Sep 16 15:56 man
drwxr-xr-x 10 mysql mysql 4096 Sep 16 15:56 mysql-test
-rw-r--r-- 1 mysql mysql 2552 Aug 29 2012 README
drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:56 scripts
drwxr-xr-x 27 mysql mysql 4096 Sep 16 15:56 share
drwxr-xr-x 4 mysql mysql 4096 Sep 16 15:56 sql-bench
drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:56 support-files
[iyunv@station1 mysql]#
# 创建Mysql存放数据文件的目录
[iyunv@station1 mysql]# mkdir /mysql_data
[iyunv@station1 mysql]# chown -R mysql:mysql /mysql_data
[iyunv@station1 mysql]#
# 初始化数据库并指定用户和数据文件位置
[iyunv@station1 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mysql_data/
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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h station1.example.com password 'new-password'
Alternatively you can run:
./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 . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
[iyunv@station1 mysql]#
[iyunv@station1 mysql]# chown -R root ./
[iyunv@station1 mysql]# ll
total 76
drwxr-xr-x 2 root mysql 4096 Sep 16 15:56 bin
-rw-r--r-- 1 root mysql 17987 Aug 29 2012 COPYING
drwxr-xr-x 4 root mysql 4096 Sep 16 15:56 data
drwxr-xr-x 2 root mysql 4096 Sep 16 15:55 docs
drwxr-xr-x 3 root mysql 4096 Sep 16 15:56 include
-rw-r--r-- 1 root mysql 7604 Aug 29 2012 INSTALL-BINARY
drwxr-xr-x 3 root mysql 4096 Sep 16 15:56 lib
drwxr-xr-x 4 root mysql 4096 Sep 16 15:56 man
drwxr-xr-x 10 root mysql 4096 Sep 16 15:56 mysql-test
-rw-r--r-- 1 root mysql 2552 Aug 29 2012 README
drwxr-xr-x 2 root mysql 4096 Sep 16 15:56 scripts
drwxr-xr-x 27 root mysql 4096 Sep 16 15:56 share
drwxr-xr-x 4 root mysql 4096 Sep 16 15:56 sql-bench
drwxr-xr-x 2 root mysql 4096 Sep 16 15:56 support-files
[iyunv@station1 mysql]#
# 复制Mysql的配置文件和启动脚本,lib库,include头文件路径
# 配置PATH搜索路径
[iyunv@station1 mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin' > /etc/profile.d/mysql.sh
[iyunv@station1 mysql]# source /etc/profile.d/mysql.sh
[iyunv@station1 mysql]#
# 测试Mysql[iyunv@station1 mysql]# /etc/init.d/mysqld start
Starting MySQL.. [ OK ]
[iyunv@station1 mysql]#
[iyunv@station1 mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.5.28-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> q
Bye
[iyunv@station1 mysql]#
[iyunv@station1 mysql]# mysqladmin -u root -p password 'fangyu421'
Enter password:
[iyunv@station1 mysql]#
[iyunv@station1 mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.5.28-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.