lamp服务一mysql部署

1.创建mysql用户

[root@lamp ~]# useradd mysql -M -s /sbin/nologin

2.解压,编译安装

[root@lamp mysql-5.1.72]# yum install gcc-c++ gcc -y 
[root@lamp ~]# tar xf mysql-5.1.72.tar.gz
[root@lamp ~]# cd mysql-5.1.72
./configure \
--prefix=/usr/local/mysql5.1.72 \
--with-unix-socket-path=/usr/local/mysql5.1.72/tmp/mysql.sock \
--localstatedir=/usr/local/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static 
出错:
checking for termcap functions library... configure: error: No curses/termcap library found
解决:
[root@lamp mysql-5.1.72]# yum install ncurses-devel -y

[root@lamp mysql-5.1.72]# make && make install

3.创建软链接

[root@lamp mysql-5.1.72]# ln -s /usr/local/mysql5.1.72/ /application/mysql 
[root@lamp ~]# cd /application/mysql/
[root@lamp mysql]# ls
bin  include  lib  libexec  mysql-test  share  sql-bench

4.初始化数据库

[root@lamp mysql-5.1.72]# cp support-files/my-small.cnf.sh /etc/my.cnf 
cp: overwrite `/etc/my.cnf'? yes
[root@lamp mysql-5.1.72]# cd /application/mysql/
[root@lamp mysql]# mkdir data
[root@lamp mysql]# chown -R mysql:mysql /application/mysql/data
[root@lamp mysql]# /application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql

4.1设置环境变量

[root@lamp mysql]# tail -1 /etc/profile
PATH=/application/mysql/bin/:$PATH
[root@lamp mysql]# source /etc/profile

4.2修改自带的脚本

[root@lamp ~]# cp mysql-5.1.72/support-files/mysql.server.sh /etc/init.d/mysqld
[root@lamp ~]# chmod +x /etc/init.d/mysqld
[root@lamp ~]# chkconfig --add /etc/init.d/mysqld 
[root@lamp ~]# vi /etc/init.d/mysqld
     46 basedir=/application/mysql
     47 datadir=/application/mysql/data
     270   pid_file=$datadir/mysqlmanager-lamp.pid
     279   server_pid_file=$datadir/lamp.pid

4.3启动mysql

[root@lamp mysql-5.1.72]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS! 
[root@lamp mysql-5.1.72]# netstat -lntup|grep mysqld
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      110960/mysqld 

4.4设置密码

[root@lamp mysql-5.1.72]# mysql_secure_installation
回车
Set root password? [Y/n] y
设置密码
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

5.登录数据库

[root@lamp mysql-5.1.72]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.72 Source distribution

Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

猜你喜欢

转载自blog.csdn.net/liang_operations/article/details/81429371
今日推荐