linux环境安装mysql
----源码、cmake方式安装mysql5.5.28----
新版mysql不能用./configure方式安装,需要cmake方式安装,尝试多次安装,以RHEL5.5x32-bit 上的成功安装总结新版mysql的安装、配置过程。
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1. 查看系统信息
a. 查看系统版本:
[root@localhost soft]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
b. 查看系统位数:
[root@localhost soft]# getconf LONG_BIT
32
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2. 准备源文件:
[root@localhost soft]# ls -lh
总计29M
-rw-r--r-- 1 root root 5.2M 12-19 16:28 cmake-2.8.
-rw-r--r-- 1 root root 24.M 12-19 16:28 mysql-5.5.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OK,现在开始我们的愉快的mysql安装之旅!!!
注意:字体为这种颜的文字记录不用关注。
1安装cmake
[root@localhost soft]# tar -zxvf cmake-2.8.
[root@localhost soft]# cd cmake-2.8.3
[root@localhost cmake-2.8.3]# ./configure
[root@localhost cmake-2.8.3]# make
[root@localhost cmake-2.8.3]# make install
2创建mysql的安装目录及数据库存放目录
[root@localhost local]# mkdir -p /usr/local/mysql //安装mysql
[root@localhost local]# mkdir -p /usr/local/mysql/data //存放数据库
3创建mysql用户及用户组
[root@localhost local]# userdel mysql //删除mysql用户
userdel:用户mysql 不存在
[root@localhost local]# groupdel mysql //删除mysql用户组
groupdel:mysql 组不存在
[root@localhost local]# groupadd mysql //添加mysql用户组
[root@localhost local]# useradd -r -g mysql mysql //添加mysql用户
4安装mysql
[root@localhost local]# tar -zxvf mysql-5.5.
[root@localhost local]# cd mysql-5.5.28
[root@localhost mysql-5.5.28]# cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-
DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1
[root@localhost local]# make
[root@localhost local]# make install
*****************************参数说明及注意事项***************************
a. cmake 参数说明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录
-DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校验字符
-DEXTRA_CHARSETS=all //安装所有扩展字符集
-DENABLED_LOCAL_INFILE=1 //允许从本地导入数据
b. 注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -
# rm -rf /etc/myf
************************************************************************* 安装完看看安装目录(/usr/local/mysql)的文件目录:
[root@localhost mysql]# ls -lh
总计76K
drwxr-xr-x 2 root root 4.0K 12-19 17:12 bin
-rw-r--r-- 1 root root 18K 08-29 16:50 COPYING
drwxr-xr-x 4 mysql mysql 4.0K 12-19 17:12 data
drwxr-xr-x 2 root root 4.0K 12-19 17:12 docs
drwxr-xr-x 3 root root 4.0K 12-19 17:12 include
-rw-r--r-- 1 root root 7.5K 08-29 16:50 INSTALL-BINARY
drwxr-xr-x 3 root root 4.0K 12-19 17:12 lib
drwxr-xr-x 4 root root 4.0K 12-19 17:12 man
drwxr-xr-x 10 root root 4.0K 12-19 17:12 mysql-test
-rw-r--r-- 1 root root 2.5K 08-29 16:50 README
drwxr-xr-x 2 root root 4.0K 12-19 17:12 scripts
drwxr-xr-x 27 root root 4.0K 12-19 17:12 share
drwxr-xr-x 4 root root 4.0K 12-19 17:12 sql-bench
drwxr-xr-x 2 root root 4.0K 12-19 17:12 support-files
5配置mysql
5.1设置目录权限
[root@localhost mysql-5.5.28]# cd /usr/local/mysql
//把当前目录中所有文件的所有者所有者设为root,所属组为mysql
[root@localhost mysql]# chown -R root:mysql .
//把data目录中所有文件的所有者所有者设为mysql,所属组为mysql
[root@localhost mysql]# chown -R mysql:mysql data
5.2将mysql的启动服务添加到系统服务中
[root@localhost mysql]# cp support-files/my-mediumf /etc/myf
5.3创建系统数据库的表
[root@localhost mysql]# cd /usr/local/mysql
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL
OK
Filling
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 localhost.localdomain 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.plmysql下载starting the server
Please report any problems with the ./bin/mysqlbug script!
5.4设置环境变量
[root@localhost mysql]# vi /root/.bash_profile
在PATH=$PATH:$HOME/bin
添加参数为:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
[root@localhost mysql]# source /root/.bash_profile
5.5手动启动、关闭mysql
[root@localhost mysql]# cd /usr/local/mysql
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql & //启动mysql但不能停止
[1] 20475
[root@localhost mysql]# 121219 17:25:17 mysqld_safe Logging to '/usr/local/mysql/data/'.
121219 17:25:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[root@localhost mysql]# ps -aux | grep mysql //查看mysql进程
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 20475 0.0 0.0 5596 1252 pts/1 S 17:25 0:00 /bin/sh ./bin/mysqld_safe --user=mysql
mysql 20714 0.2 1.8 326708 35124 pts/1 Sl 17:25 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/
--pid-file=/usr/local/mysql/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306 root 20736 0.0 0.0 5024 704 pts/1 R+ 17:26 0:00 grep mysql
[root@localhost mysql]# mysqladmin -u root -p shutdown //关闭mysql,这里MySQL的root用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论