LNMP(Linux+Nginx+MySQL+PHP)服务器环境配置(3)

五、编译安装MySQL

建立mysql组,建立mysql用户并且加入到mysql组中
# groupadd mysql
# useradd mysql -g mysql
[root@linux lnmp]# tar zxvf mysql-5.1.35.tar.gz
[root@linux lnmp]# cd mysql-5.1.35
# ./configure --prefix=/usr/local/mysql
--without-debug
--with-extra-charsets=gbk
--with-extra-charsets=all
--enable-assembler
--with-pthread
--enable-thread-safe-client
--with-mysqld-ldflags=-all-static  /*不带共享库的形式编译mysqld*/
--with-client-ldflags=-all-static
--with-big-tables
--with-readline    /*要采用rpm方式安装ncurses或tar包安装*/
--with-ssl            /*要采用rpm方式安装openssl*/
--with-embedded-server
--enable-local-infile
--with-plugins=innobase
# make && make install

# /usr/local/mysql/bin/mysql_install_db --user=mysql
#以mysql身份初始化数据库
# cp ./support-files/mysql.server /etc/init.d/mysql
#复制Mysql启动服务至系统
# cp ./support-files/my-medium.cnf /etc/my.cnf
# chmod 755 /etc/init.d/mysql

# cd /usr/local/mysql/   #切换到cd /usr/local/mysql/目录下
# chown -R mysql .       #改变当前目录下的所有者为mysql用户
# chown -R mysql var     #修改数据库目录的权限
# chgrp -R mysql .       #改变当前目录下的mysql用户的文件为mysql组

# /usr/local/mysql/bin/mysqld_safe --user=mysql&
# /usr/local/mysql/bin/mysqladmin -u root password 'admin' #设置管理员密码

[root@linux html]# /usr/local/mysql/bin/mysql -u root -p   #测试密码输入
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.35-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \q       /*退出mysql*/

# chkconfig --add mysql  #添加mysqld服务到系统
# chkconfig mysql on     #打开myslqd服务
# service mysql start    #启动Mysql
#/usr/local/mysql/bin/mysqladmin shutdown  #关闭数据库

#查看mysql端口的打开情况
# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address   Foreign Address  State   PID/P name
tcp        0      0 0.0.0.0:3306    0.0.0.0:*        LISTEN  2936/   
#查看是否启动:
#ps -ef | grep mysql
注:在配置过程中,整体的配置思路从上往下,其中的一些功能可以用在实际的配置过程中,主要用于测试环节中。
Mysql的优化部分这里没有给出,需要参考其它资料。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2ea13149b486bb52e9aee7c424e920e2.html